{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 二手车价格预测     \n",
    "\n",
    "used_car_train_20200313.csv     used_car_testB_20200421.csv     数据来自某交易平台的二手车交易记录     https://tianchi.aliyun.com/competition/entrance/231784/introduction     ToDo：给你一辆车的各个属性（除了price字段），预测它的价格     使用神经网络来完成预测"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 104,
   "metadata": {},
   "outputs": [],
   "source": [
    "import pandas as pd\n",
    "import numpy as np"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 105,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>SaleID</th>\n",
       "      <th>name</th>\n",
       "      <th>regDate</th>\n",
       "      <th>model</th>\n",
       "      <th>brand</th>\n",
       "      <th>bodyType</th>\n",
       "      <th>fuelType</th>\n",
       "      <th>gearbox</th>\n",
       "      <th>power</th>\n",
       "      <th>kilometer</th>\n",
       "      <th>...</th>\n",
       "      <th>v_5</th>\n",
       "      <th>v_6</th>\n",
       "      <th>v_7</th>\n",
       "      <th>v_8</th>\n",
       "      <th>v_9</th>\n",
       "      <th>v_10</th>\n",
       "      <th>v_11</th>\n",
       "      <th>v_12</th>\n",
       "      <th>v_13</th>\n",
       "      <th>v_14</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>0</td>\n",
       "      <td>736</td>\n",
       "      <td>20040402</td>\n",
       "      <td>30.0</td>\n",
       "      <td>6</td>\n",
       "      <td>1.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>60</td>\n",
       "      <td>12.5</td>\n",
       "      <td>...</td>\n",
       "      <td>0.235676</td>\n",
       "      <td>0.101988</td>\n",
       "      <td>0.129549</td>\n",
       "      <td>0.022816</td>\n",
       "      <td>0.097462</td>\n",
       "      <td>-2.881803</td>\n",
       "      <td>2.804097</td>\n",
       "      <td>-2.420821</td>\n",
       "      <td>0.795292</td>\n",
       "      <td>0.914762</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>1</td>\n",
       "      <td>2262</td>\n",
       "      <td>20030301</td>\n",
       "      <td>40.0</td>\n",
       "      <td>1</td>\n",
       "      <td>2.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0</td>\n",
       "      <td>15.0</td>\n",
       "      <td>...</td>\n",
       "      <td>0.264777</td>\n",
       "      <td>0.121004</td>\n",
       "      <td>0.135731</td>\n",
       "      <td>0.026597</td>\n",
       "      <td>0.020582</td>\n",
       "      <td>-4.900482</td>\n",
       "      <td>2.096338</td>\n",
       "      <td>-1.030483</td>\n",
       "      <td>-1.722674</td>\n",
       "      <td>0.245522</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>2</td>\n",
       "      <td>14874</td>\n",
       "      <td>20040403</td>\n",
       "      <td>115.0</td>\n",
       "      <td>15</td>\n",
       "      <td>1.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>163</td>\n",
       "      <td>12.5</td>\n",
       "      <td>...</td>\n",
       "      <td>0.251410</td>\n",
       "      <td>0.114912</td>\n",
       "      <td>0.165147</td>\n",
       "      <td>0.062173</td>\n",
       "      <td>0.027075</td>\n",
       "      <td>-4.846749</td>\n",
       "      <td>1.803559</td>\n",
       "      <td>1.565330</td>\n",
       "      <td>-0.832687</td>\n",
       "      <td>-0.229963</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>3</td>\n",
       "      <td>71865</td>\n",
       "      <td>19960908</td>\n",
       "      <td>109.0</td>\n",
       "      <td>10</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>193</td>\n",
       "      <td>15.0</td>\n",
       "      <td>...</td>\n",
       "      <td>0.274293</td>\n",
       "      <td>0.110300</td>\n",
       "      <td>0.121964</td>\n",
       "      <td>0.033395</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>-4.509599</td>\n",
       "      <td>1.285940</td>\n",
       "      <td>-0.501868</td>\n",
       "      <td>-2.438353</td>\n",
       "      <td>-0.478699</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>4</td>\n",
       "      <td>111080</td>\n",
       "      <td>20120103</td>\n",
       "      <td>110.0</td>\n",
       "      <td>5</td>\n",
       "      <td>1.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>68</td>\n",
       "      <td>5.0</td>\n",
       "      <td>...</td>\n",
       "      <td>0.228036</td>\n",
       "      <td>0.073205</td>\n",
       "      <td>0.091880</td>\n",
       "      <td>0.078819</td>\n",
       "      <td>0.121534</td>\n",
       "      <td>-1.896240</td>\n",
       "      <td>0.910783</td>\n",
       "      <td>0.931110</td>\n",
       "      <td>2.834518</td>\n",
       "      <td>1.923482</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>149995</th>\n",
       "      <td>149995</td>\n",
       "      <td>163978</td>\n",
       "      <td>20000607</td>\n",
       "      <td>121.0</td>\n",
       "      <td>10</td>\n",
       "      <td>4.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>163</td>\n",
       "      <td>15.0</td>\n",
       "      <td>...</td>\n",
       "      <td>0.280264</td>\n",
       "      <td>0.000310</td>\n",
       "      <td>0.048441</td>\n",
       "      <td>0.071158</td>\n",
       "      <td>0.019174</td>\n",
       "      <td>1.988114</td>\n",
       "      <td>-2.983973</td>\n",
       "      <td>0.589167</td>\n",
       "      <td>-1.304370</td>\n",
       "      <td>-0.302592</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>149996</th>\n",
       "      <td>149996</td>\n",
       "      <td>184535</td>\n",
       "      <td>20091102</td>\n",
       "      <td>116.0</td>\n",
       "      <td>11</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>125</td>\n",
       "      <td>10.0</td>\n",
       "      <td>...</td>\n",
       "      <td>0.253217</td>\n",
       "      <td>0.000777</td>\n",
       "      <td>0.084079</td>\n",
       "      <td>0.099681</td>\n",
       "      <td>0.079371</td>\n",
       "      <td>1.839166</td>\n",
       "      <td>-2.774615</td>\n",
       "      <td>2.553994</td>\n",
       "      <td>0.924196</td>\n",
       "      <td>-0.272160</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>149997</th>\n",
       "      <td>149997</td>\n",
       "      <td>147587</td>\n",
       "      <td>20101003</td>\n",
       "      <td>60.0</td>\n",
       "      <td>11</td>\n",
       "      <td>1.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>90</td>\n",
       "      <td>6.0</td>\n",
       "      <td>...</td>\n",
       "      <td>0.233353</td>\n",
       "      <td>0.000705</td>\n",
       "      <td>0.118872</td>\n",
       "      <td>0.100118</td>\n",
       "      <td>0.097914</td>\n",
       "      <td>2.439812</td>\n",
       "      <td>-1.630677</td>\n",
       "      <td>2.290197</td>\n",
       "      <td>1.891922</td>\n",
       "      <td>0.414931</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>149998</th>\n",
       "      <td>149998</td>\n",
       "      <td>45907</td>\n",
       "      <td>20060312</td>\n",
       "      <td>34.0</td>\n",
       "      <td>10</td>\n",
       "      <td>3.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>156</td>\n",
       "      <td>15.0</td>\n",
       "      <td>...</td>\n",
       "      <td>0.256369</td>\n",
       "      <td>0.000252</td>\n",
       "      <td>0.081479</td>\n",
       "      <td>0.083558</td>\n",
       "      <td>0.081498</td>\n",
       "      <td>2.075380</td>\n",
       "      <td>-2.633719</td>\n",
       "      <td>1.414937</td>\n",
       "      <td>0.431981</td>\n",
       "      <td>-1.659014</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>149999</th>\n",
       "      <td>149999</td>\n",
       "      <td>177672</td>\n",
       "      <td>19990204</td>\n",
       "      <td>19.0</td>\n",
       "      <td>28</td>\n",
       "      <td>6.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>193</td>\n",
       "      <td>12.5</td>\n",
       "      <td>...</td>\n",
       "      <td>0.284475</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.040072</td>\n",
       "      <td>0.062543</td>\n",
       "      <td>0.025819</td>\n",
       "      <td>1.978453</td>\n",
       "      <td>-3.179913</td>\n",
       "      <td>0.031724</td>\n",
       "      <td>-1.483350</td>\n",
       "      <td>-0.342674</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>150000 rows × 31 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "        SaleID    name   regDate  model  brand  bodyType  fuelType  gearbox  \\\n",
       "0            0     736  20040402   30.0      6       1.0       0.0      0.0   \n",
       "1            1    2262  20030301   40.0      1       2.0       0.0      0.0   \n",
       "2            2   14874  20040403  115.0     15       1.0       0.0      0.0   \n",
       "3            3   71865  19960908  109.0     10       0.0       0.0      1.0   \n",
       "4            4  111080  20120103  110.0      5       1.0       0.0      0.0   \n",
       "...        ...     ...       ...    ...    ...       ...       ...      ...   \n",
       "149995  149995  163978  20000607  121.0     10       4.0       0.0      1.0   \n",
       "149996  149996  184535  20091102  116.0     11       0.0       0.0      0.0   \n",
       "149997  149997  147587  20101003   60.0     11       1.0       1.0      0.0   \n",
       "149998  149998   45907  20060312   34.0     10       3.0       1.0      0.0   \n",
       "149999  149999  177672  19990204   19.0     28       6.0       0.0      1.0   \n",
       "\n",
       "        power  kilometer  ...       v_5       v_6       v_7       v_8  \\\n",
       "0          60       12.5  ...  0.235676  0.101988  0.129549  0.022816   \n",
       "1           0       15.0  ...  0.264777  0.121004  0.135731  0.026597   \n",
       "2         163       12.5  ...  0.251410  0.114912  0.165147  0.062173   \n",
       "3         193       15.0  ...  0.274293  0.110300  0.121964  0.033395   \n",
       "4          68        5.0  ...  0.228036  0.073205  0.091880  0.078819   \n",
       "...       ...        ...  ...       ...       ...       ...       ...   \n",
       "149995    163       15.0  ...  0.280264  0.000310  0.048441  0.071158   \n",
       "149996    125       10.0  ...  0.253217  0.000777  0.084079  0.099681   \n",
       "149997     90        6.0  ...  0.233353  0.000705  0.118872  0.100118   \n",
       "149998    156       15.0  ...  0.256369  0.000252  0.081479  0.083558   \n",
       "149999    193       12.5  ...  0.284475  0.000000  0.040072  0.062543   \n",
       "\n",
       "             v_9      v_10      v_11      v_12      v_13      v_14  \n",
       "0       0.097462 -2.881803  2.804097 -2.420821  0.795292  0.914762  \n",
       "1       0.020582 -4.900482  2.096338 -1.030483 -1.722674  0.245522  \n",
       "2       0.027075 -4.846749  1.803559  1.565330 -0.832687 -0.229963  \n",
       "3       0.000000 -4.509599  1.285940 -0.501868 -2.438353 -0.478699  \n",
       "4       0.121534 -1.896240  0.910783  0.931110  2.834518  1.923482  \n",
       "...          ...       ...       ...       ...       ...       ...  \n",
       "149995  0.019174  1.988114 -2.983973  0.589167 -1.304370 -0.302592  \n",
       "149996  0.079371  1.839166 -2.774615  2.553994  0.924196 -0.272160  \n",
       "149997  0.097914  2.439812 -1.630677  2.290197  1.891922  0.414931  \n",
       "149998  0.081498  2.075380 -2.633719  1.414937  0.431981 -1.659014  \n",
       "149999  0.025819  1.978453 -3.179913  0.031724 -1.483350 -0.342674  \n",
       "\n",
       "[150000 rows x 31 columns]"
      ]
     },
     "execution_count": 105,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 数据加载\n",
    "train_data = pd.read_csv('./used_car_train_20200313.csv',sep=' ')\n",
    "train_data"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 139,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0         20040402\n",
       "1         20030301\n",
       "2         20040403\n",
       "3         19960908\n",
       "4         20120103\n",
       "            ...   \n",
       "149995    20000607\n",
       "149996    20091102\n",
       "149997    20101003\n",
       "149998    20060312\n",
       "149999    19990204\n",
       "Name: regDate, Length: 150000, dtype: int64"
      ]
     },
     "execution_count": 139,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "train_data['regDate']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 140,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "19910001"
      ]
     },
     "execution_count": 140,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "np.min(train_data['regDate'])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 141,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0        2004-04-02\n",
       "1        2003-03-01\n",
       "2        2004-04-03\n",
       "3        1996-09-08\n",
       "4        2012-01-03\n",
       "            ...    \n",
       "149995   2000-06-07\n",
       "149996   2009-11-02\n",
       "149997   2010-10-03\n",
       "149998   2006-03-12\n",
       "149999   1999-02-04\n",
       "Name: regDate, Length: 150000, dtype: datetime64[ns]"
      ]
     },
     "execution_count": 141,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 汽车的展示时间\n",
    "# temp = pd.to_datetime(train_data['regDate'],format='%Y%m%d',errors='coerce') # 0月会有异常，coerce避免异常\n",
    "# temp"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 142,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "19910001\n",
      "20150618\n"
     ]
    }
   ],
   "source": [
    "# print(np.min(train_data['regDate']))\n",
    "# print(np.min(train_data['creatDate']))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 143,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(Timestamp('1991-01-01 00:00:00'), Timestamp('2015-06-01 00:00:00'))"
      ]
     },
     "execution_count": 143,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 设定一个差分的时间锚点，保证结果为正即可\n",
    "# min_date = pd.to_datetime('19910101',format='%Y%m%d')\n",
    "# min_date2 = pd.to_datetime('20150601',format='%Y%m%d')\n",
    "# min_date,min_date2"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 144,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0         4840.0\n",
       "1         4442.0\n",
       "2         4841.0\n",
       "3         2077.0\n",
       "4         7672.0\n",
       "           ...  \n",
       "149995    3445.0\n",
       "149996    6880.0\n",
       "149997    7215.0\n",
       "149998    5549.0\n",
       "149999    2956.0\n",
       "Name: regTime, Length: 150000, dtype: float64"
      ]
     },
     "execution_count": 144,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 将regDate（汽车注册）转换为时间diff\n",
    "# train_data['regTime'] = (temp - min_date).dt.days # dt.days对datetime后的内容取天的数字\n",
    "# train_data['regTime']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 145,
   "metadata": {},
   "outputs": [],
   "source": [
    "# 将creatDate（汽车售卖）转换为汽车损耗时间（既时间diff）\n",
    "# train_data['creatTime'] = (pd.to_datetime(train_data['creatDate'],format='%Y%m%d',errors='coerce')-min_date).dt.days\n",
    "# # 汽车的使用时间\n",
    "# train_data['usedTime'] = train_data['creatTime'] - train_data['regTime']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 146,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0        9225 days\n",
       "1        9199 days\n",
       "2        9223 days\n",
       "3        9202 days\n",
       "4        9203 days\n",
       "            ...   \n",
       "149995   9217 days\n",
       "149996   9202 days\n",
       "149997   9218 days\n",
       "149998   9222 days\n",
       "149999   9195 days\n",
       "Name: creatDate, Length: 150000, dtype: timedelta64[ns]"
      ]
     },
     "execution_count": 146,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# (pd.to_datetime(train_data['creatDate'],format='%Y%m%d',errors='coerce')-min_date)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 106,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>SaleID</th>\n",
       "      <th>price</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>150000</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>150001</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>150002</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>150003</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>150004</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>49995</th>\n",
       "      <td>199995</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>49996</th>\n",
       "      <td>199996</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>49997</th>\n",
       "      <td>199997</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>49998</th>\n",
       "      <td>199998</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>49999</th>\n",
       "      <td>199999</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>50000 rows × 2 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "       SaleID  price\n",
       "0      150000      0\n",
       "1      150001      0\n",
       "2      150002      0\n",
       "3      150003      0\n",
       "4      150004      0\n",
       "...       ...    ...\n",
       "49995  199995      0\n",
       "49996  199996      0\n",
       "49997  199997      0\n",
       "49998  199998      0\n",
       "49999  199999      0\n",
       "\n",
       "[50000 rows x 2 columns]"
      ]
     },
     "execution_count": 106,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 提交数据格式读取\n",
    "sample_data = pd.read_csv('./used_car_sample_submit.csv')\n",
    "sample_data"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 107,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>SaleID</th>\n",
       "      <th>name</th>\n",
       "      <th>regDate</th>\n",
       "      <th>model</th>\n",
       "      <th>brand</th>\n",
       "      <th>bodyType</th>\n",
       "      <th>fuelType</th>\n",
       "      <th>gearbox</th>\n",
       "      <th>power</th>\n",
       "      <th>kilometer</th>\n",
       "      <th>...</th>\n",
       "      <th>v_5</th>\n",
       "      <th>v_6</th>\n",
       "      <th>v_7</th>\n",
       "      <th>v_8</th>\n",
       "      <th>v_9</th>\n",
       "      <th>v_10</th>\n",
       "      <th>v_11</th>\n",
       "      <th>v_12</th>\n",
       "      <th>v_13</th>\n",
       "      <th>v_14</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>200000</td>\n",
       "      <td>133777</td>\n",
       "      <td>20000501</td>\n",
       "      <td>67.0</td>\n",
       "      <td>0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>101</td>\n",
       "      <td>15.0</td>\n",
       "      <td>...</td>\n",
       "      <td>0.236520</td>\n",
       "      <td>0.000241</td>\n",
       "      <td>0.105319</td>\n",
       "      <td>0.046233</td>\n",
       "      <td>0.094522</td>\n",
       "      <td>3.619512</td>\n",
       "      <td>-0.280607</td>\n",
       "      <td>-2.019761</td>\n",
       "      <td>0.978828</td>\n",
       "      <td>0.803322</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>200001</td>\n",
       "      <td>61206</td>\n",
       "      <td>19950211</td>\n",
       "      <td>19.0</td>\n",
       "      <td>6</td>\n",
       "      <td>2.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>73</td>\n",
       "      <td>6.0</td>\n",
       "      <td>...</td>\n",
       "      <td>0.261518</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.120323</td>\n",
       "      <td>0.046784</td>\n",
       "      <td>0.035385</td>\n",
       "      <td>2.997376</td>\n",
       "      <td>-1.406705</td>\n",
       "      <td>-1.020884</td>\n",
       "      <td>-1.349990</td>\n",
       "      <td>-0.200542</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>200002</td>\n",
       "      <td>67829</td>\n",
       "      <td>20090606</td>\n",
       "      <td>5.0</td>\n",
       "      <td>5</td>\n",
       "      <td>4.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>120</td>\n",
       "      <td>5.0</td>\n",
       "      <td>...</td>\n",
       "      <td>0.261691</td>\n",
       "      <td>0.090836</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.079655</td>\n",
       "      <td>0.073586</td>\n",
       "      <td>-3.951084</td>\n",
       "      <td>-0.433467</td>\n",
       "      <td>0.918964</td>\n",
       "      <td>1.634604</td>\n",
       "      <td>1.027173</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>200003</td>\n",
       "      <td>8892</td>\n",
       "      <td>20020601</td>\n",
       "      <td>22.0</td>\n",
       "      <td>9</td>\n",
       "      <td>1.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>58</td>\n",
       "      <td>15.0</td>\n",
       "      <td>...</td>\n",
       "      <td>0.236050</td>\n",
       "      <td>0.101777</td>\n",
       "      <td>0.098950</td>\n",
       "      <td>0.026830</td>\n",
       "      <td>0.096614</td>\n",
       "      <td>-2.846788</td>\n",
       "      <td>2.800267</td>\n",
       "      <td>-2.524610</td>\n",
       "      <td>1.076819</td>\n",
       "      <td>0.461610</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>200004</td>\n",
       "      <td>76998</td>\n",
       "      <td>20030301</td>\n",
       "      <td>46.0</td>\n",
       "      <td>6</td>\n",
       "      <td>0.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0.0</td>\n",
       "      <td>116</td>\n",
       "      <td>15.0</td>\n",
       "      <td>...</td>\n",
       "      <td>0.257000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.066732</td>\n",
       "      <td>0.057771</td>\n",
       "      <td>0.068852</td>\n",
       "      <td>2.839010</td>\n",
       "      <td>-1.659801</td>\n",
       "      <td>-0.924142</td>\n",
       "      <td>0.199423</td>\n",
       "      <td>0.451014</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>49995</th>\n",
       "      <td>249995</td>\n",
       "      <td>111443</td>\n",
       "      <td>20041005</td>\n",
       "      <td>4.0</td>\n",
       "      <td>4</td>\n",
       "      <td>0.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>1.0</td>\n",
       "      <td>150</td>\n",
       "      <td>15.0</td>\n",
       "      <td>...</td>\n",
       "      <td>0.263668</td>\n",
       "      <td>0.000292</td>\n",
       "      <td>0.141804</td>\n",
       "      <td>0.076393</td>\n",
       "      <td>0.039272</td>\n",
       "      <td>2.072901</td>\n",
       "      <td>-2.531869</td>\n",
       "      <td>1.716978</td>\n",
       "      <td>-1.063437</td>\n",
       "      <td>0.326587</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>49996</th>\n",
       "      <td>249996</td>\n",
       "      <td>152834</td>\n",
       "      <td>20130409</td>\n",
       "      <td>65.0</td>\n",
       "      <td>1</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>179</td>\n",
       "      <td>4.0</td>\n",
       "      <td>...</td>\n",
       "      <td>0.255310</td>\n",
       "      <td>0.000991</td>\n",
       "      <td>0.155868</td>\n",
       "      <td>0.108425</td>\n",
       "      <td>0.067841</td>\n",
       "      <td>1.358504</td>\n",
       "      <td>-3.290295</td>\n",
       "      <td>4.269809</td>\n",
       "      <td>0.140524</td>\n",
       "      <td>0.556221</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>49997</th>\n",
       "      <td>249997</td>\n",
       "      <td>132531</td>\n",
       "      <td>20041211</td>\n",
       "      <td>4.0</td>\n",
       "      <td>4</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>147</td>\n",
       "      <td>12.5</td>\n",
       "      <td>...</td>\n",
       "      <td>0.262933</td>\n",
       "      <td>0.000318</td>\n",
       "      <td>0.141872</td>\n",
       "      <td>0.071968</td>\n",
       "      <td>0.042966</td>\n",
       "      <td>2.165658</td>\n",
       "      <td>-2.417885</td>\n",
       "      <td>1.370612</td>\n",
       "      <td>-1.073133</td>\n",
       "      <td>0.270602</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>49998</th>\n",
       "      <td>249998</td>\n",
       "      <td>143405</td>\n",
       "      <td>20020702</td>\n",
       "      <td>40.0</td>\n",
       "      <td>1</td>\n",
       "      <td>4.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>176</td>\n",
       "      <td>15.0</td>\n",
       "      <td>...</td>\n",
       "      <td>0.282106</td>\n",
       "      <td>0.000023</td>\n",
       "      <td>0.067483</td>\n",
       "      <td>0.067526</td>\n",
       "      <td>0.009006</td>\n",
       "      <td>2.030114</td>\n",
       "      <td>-2.939244</td>\n",
       "      <td>0.569078</td>\n",
       "      <td>-1.718245</td>\n",
       "      <td>0.316379</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>49999</th>\n",
       "      <td>249999</td>\n",
       "      <td>78202</td>\n",
       "      <td>20090708</td>\n",
       "      <td>32.0</td>\n",
       "      <td>8</td>\n",
       "      <td>1.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0</td>\n",
       "      <td>3.0</td>\n",
       "      <td>...</td>\n",
       "      <td>0.231449</td>\n",
       "      <td>0.103947</td>\n",
       "      <td>0.096027</td>\n",
       "      <td>0.062328</td>\n",
       "      <td>0.110180</td>\n",
       "      <td>-3.689090</td>\n",
       "      <td>2.032376</td>\n",
       "      <td>0.109157</td>\n",
       "      <td>2.202828</td>\n",
       "      <td>0.847469</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>50000 rows × 30 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "       SaleID    name   regDate  model  brand  bodyType  fuelType  gearbox  \\\n",
       "0      200000  133777  20000501   67.0      0       1.0       0.0      0.0   \n",
       "1      200001   61206  19950211   19.0      6       2.0       0.0      0.0   \n",
       "2      200002   67829  20090606    5.0      5       4.0       0.0      0.0   \n",
       "3      200003    8892  20020601   22.0      9       1.0       0.0      0.0   \n",
       "4      200004   76998  20030301   46.0      6       0.0       NaN      0.0   \n",
       "...       ...     ...       ...    ...    ...       ...       ...      ...   \n",
       "49995  249995  111443  20041005    4.0      4       0.0       NaN      1.0   \n",
       "49996  249996  152834  20130409   65.0      1       0.0       0.0      0.0   \n",
       "49997  249997  132531  20041211    4.0      4       0.0       0.0      1.0   \n",
       "49998  249998  143405  20020702   40.0      1       4.0       0.0      1.0   \n",
       "49999  249999   78202  20090708   32.0      8       1.0       0.0      0.0   \n",
       "\n",
       "       power  kilometer  ...       v_5       v_6       v_7       v_8  \\\n",
       "0        101       15.0  ...  0.236520  0.000241  0.105319  0.046233   \n",
       "1         73        6.0  ...  0.261518  0.000000  0.120323  0.046784   \n",
       "2        120        5.0  ...  0.261691  0.090836  0.000000  0.079655   \n",
       "3         58       15.0  ...  0.236050  0.101777  0.098950  0.026830   \n",
       "4        116       15.0  ...  0.257000  0.000000  0.066732  0.057771   \n",
       "...      ...        ...  ...       ...       ...       ...       ...   \n",
       "49995    150       15.0  ...  0.263668  0.000292  0.141804  0.076393   \n",
       "49996    179        4.0  ...  0.255310  0.000991  0.155868  0.108425   \n",
       "49997    147       12.5  ...  0.262933  0.000318  0.141872  0.071968   \n",
       "49998    176       15.0  ...  0.282106  0.000023  0.067483  0.067526   \n",
       "49999      0        3.0  ...  0.231449  0.103947  0.096027  0.062328   \n",
       "\n",
       "            v_9      v_10      v_11      v_12      v_13      v_14  \n",
       "0      0.094522  3.619512 -0.280607 -2.019761  0.978828  0.803322  \n",
       "1      0.035385  2.997376 -1.406705 -1.020884 -1.349990 -0.200542  \n",
       "2      0.073586 -3.951084 -0.433467  0.918964  1.634604  1.027173  \n",
       "3      0.096614 -2.846788  2.800267 -2.524610  1.076819  0.461610  \n",
       "4      0.068852  2.839010 -1.659801 -0.924142  0.199423  0.451014  \n",
       "...         ...       ...       ...       ...       ...       ...  \n",
       "49995  0.039272  2.072901 -2.531869  1.716978 -1.063437  0.326587  \n",
       "49996  0.067841  1.358504 -3.290295  4.269809  0.140524  0.556221  \n",
       "49997  0.042966  2.165658 -2.417885  1.370612 -1.073133  0.270602  \n",
       "49998  0.009006  2.030114 -2.939244  0.569078 -1.718245  0.316379  \n",
       "49999  0.110180 -3.689090  2.032376  0.109157  2.202828  0.847469  \n",
       "\n",
       "[50000 rows x 30 columns]"
      ]
     },
     "execution_count": 107,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# test数据读取\n",
    "test_data = pd.read_csv('./used_car_testB_20200421.csv',sep=' ')\n",
    "test_data"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "print(np.min(test_data['regDate']))\n",
    "print(np.min(test_data['creatDate']))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 148,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<class 'pandas.core.frame.DataFrame'>\n",
      "RangeIndex: 150000 entries, 0 to 149999\n",
      "Data columns (total 34 columns):\n",
      " #   Column             Non-Null Count   Dtype  \n",
      "---  ------             --------------   -----  \n",
      " 0   SaleID             150000 non-null  int64  \n",
      " 1   name               150000 non-null  int64  \n",
      " 2   regDate            150000 non-null  int64  \n",
      " 3   model              149999 non-null  float64\n",
      " 4   brand              150000 non-null  int64  \n",
      " 5   bodyType           145494 non-null  float64\n",
      " 6   fuelType           141320 non-null  float64\n",
      " 7   gearbox            144019 non-null  float64\n",
      " 8   power              150000 non-null  int64  \n",
      " 9   kilometer          150000 non-null  float64\n",
      " 10  notRepairedDamage  150000 non-null  object \n",
      " 11  regionCode         150000 non-null  int64  \n",
      " 12  seller             150000 non-null  int64  \n",
      " 13  offerType          150000 non-null  int64  \n",
      " 14  creatDate          150000 non-null  int64  \n",
      " 15  price              150000 non-null  int64  \n",
      " 16  v_0                150000 non-null  float64\n",
      " 17  v_1                150000 non-null  float64\n",
      " 18  v_2                150000 non-null  float64\n",
      " 19  v_3                150000 non-null  float64\n",
      " 20  v_4                150000 non-null  float64\n",
      " 21  v_5                150000 non-null  float64\n",
      " 22  v_6                150000 non-null  float64\n",
      " 23  v_7                150000 non-null  float64\n",
      " 24  v_8                150000 non-null  float64\n",
      " 25  v_9                150000 non-null  float64\n",
      " 26  v_10               150000 non-null  float64\n",
      " 27  v_11               150000 non-null  float64\n",
      " 28  v_12               150000 non-null  float64\n",
      " 29  v_13               150000 non-null  float64\n",
      " 30  v_14               150000 non-null  float64\n",
      " 31  regTime            138653 non-null  float64\n",
      " 32  creatTime          150000 non-null  int64  \n",
      " 33  usedTime           138653 non-null  float64\n",
      "dtypes: float64(22), int64(11), object(1)\n",
      "memory usage: 38.9+ MB\n"
     ]
    }
   ],
   "source": [
    "train_data.info()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 108,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "0.0    111361\n",
      "-       24324\n",
      "1.0     14315\n",
      "Name: notRepairedDamage, dtype: int64\n",
      "0.0    135685\n",
      "1.0     14315\n",
      "Name: notRepairedDamage, dtype: int64\n"
     ]
    }
   ],
   "source": [
    "# -为缺失值，补全,分类任务众数补全\n",
    "print(train_data['notRepairedDamage'].value_counts())\n",
    "train_data['notRepairedDamage'].replace('-','0.0',inplace=True) # 0.0 直接在补全的过程中将object转换成float\n",
    "train_data['notRepairedDamage'] = train_data['notRepairedDamage'].astype('float64')\n",
    "print(train_data['notRepairedDamage'].value_counts())"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 109,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "0.0    37224\n",
      "-       8069\n",
      "1.0     4707\n",
      "Name: notRepairedDamage, dtype: int64\n",
      "0.0    45293\n",
      "1.0     4707\n",
      "Name: notRepairedDamage, dtype: int64\n"
     ]
    }
   ],
   "source": [
    "# object类型-为缺失值，补全,分类任务众数补全,类型转换成float\n",
    "print(test_data['notRepairedDamage'].value_counts())\n",
    "test_data['notRepairedDamage'].replace('-','0.0',inplace=True)\n",
    "test_data['notRepairedDamage'] = test_data['notRepairedDamage'].astype('float64')\n",
    "print(test_data['notRepairedDamage'].value_counts())"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "常用补全有众数、中位数、KNN补全，补全后的可以作为新列特征"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 199,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0       12829\n",
       "75       9593\n",
       "150      6495\n",
       "60       6374\n",
       "140      5963\n",
       "        ...  \n",
       "1597        1\n",
       "1596        1\n",
       "572         1\n",
       "316         1\n",
       "575         1\n",
       "Name: power, Length: 566, dtype: int64"
      ]
     },
     "execution_count": 199,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "train_data.power.value_counts()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 200,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "count    150000.000000\n",
      "mean        116.860973\n",
      "std          70.075256\n",
      "min           0.000000\n",
      "25%          75.000000\n",
      "50%         110.000000\n",
      "75%         150.000000\n",
      "max         600.000000\n",
      "Name: power, dtype: float64\n",
      "count    50000.00000\n",
      "mean       116.51788\n",
      "std         70.48107\n",
      "min          0.00000\n",
      "25%         75.00000\n",
      "50%        110.00000\n",
      "75%        150.00000\n",
      "max        600.00000\n",
      "Name: power, dtype: float64\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "<ipython-input-200-eaa3f0819c70>:1: SettingWithCopyWarning: \n",
      "A value is trying to be set on a copy of a slice from a DataFrame\n",
      "\n",
      "See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
      "  train_data['power'][train_data['power']>600]=600\n",
      "<ipython-input-200-eaa3f0819c70>:3: SettingWithCopyWarning: \n",
      "A value is trying to be set on a copy of a slice from a DataFrame\n",
      "\n",
      "See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
      "  test_data['power'][test_data['power']>600]=600\n"
     ]
    }
   ],
   "source": [
    "train_data['power'][train_data['power']>600]=600\n",
    "print(train_data['power'].describe())\n",
    "test_data['power'][test_data['power']>600]=600\n",
    "print(test_data['power'].describe())"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 110,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<class 'pandas.core.frame.DataFrame'>\n",
      "RangeIndex: 150000 entries, 0 to 149999\n",
      "Data columns (total 31 columns):\n",
      " #   Column             Non-Null Count   Dtype  \n",
      "---  ------             --------------   -----  \n",
      " 0   SaleID             150000 non-null  int64  \n",
      " 1   name               150000 non-null  int64  \n",
      " 2   regDate            150000 non-null  int64  \n",
      " 3   model              149999 non-null  float64\n",
      " 4   brand              150000 non-null  int64  \n",
      " 5   bodyType           145494 non-null  float64\n",
      " 6   fuelType           141320 non-null  float64\n",
      " 7   gearbox            144019 non-null  float64\n",
      " 8   power              150000 non-null  int64  \n",
      " 9   kilometer          150000 non-null  float64\n",
      " 10  notRepairedDamage  150000 non-null  float64\n",
      " 11  regionCode         150000 non-null  int64  \n",
      " 12  seller             150000 non-null  int64  \n",
      " 13  offerType          150000 non-null  int64  \n",
      " 14  creatDate          150000 non-null  int64  \n",
      " 15  price              150000 non-null  int64  \n",
      " 16  v_0                150000 non-null  float64\n",
      " 17  v_1                150000 non-null  float64\n",
      " 18  v_2                150000 non-null  float64\n",
      " 19  v_3                150000 non-null  float64\n",
      " 20  v_4                150000 non-null  float64\n",
      " 21  v_5                150000 non-null  float64\n",
      " 22  v_6                150000 non-null  float64\n",
      " 23  v_7                150000 non-null  float64\n",
      " 24  v_8                150000 non-null  float64\n",
      " 25  v_9                150000 non-null  float64\n",
      " 26  v_10               150000 non-null  float64\n",
      " 27  v_11               150000 non-null  float64\n",
      " 28  v_12               150000 non-null  float64\n",
      " 29  v_13               150000 non-null  float64\n",
      " 30  v_14               150000 non-null  float64\n",
      "dtypes: float64(21), int64(10)\n",
      "memory usage: 35.5 MB\n"
     ]
    }
   ],
   "source": [
    "train_data.info()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 111,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "SaleID                  0\n",
       "name                    0\n",
       "regDate                 0\n",
       "model                   1\n",
       "brand                   0\n",
       "bodyType             4506\n",
       "fuelType             8680\n",
       "gearbox              5981\n",
       "power                   0\n",
       "kilometer               0\n",
       "notRepairedDamage       0\n",
       "regionCode              0\n",
       "seller                  0\n",
       "offerType               0\n",
       "creatDate               0\n",
       "price                   0\n",
       "v_0                     0\n",
       "v_1                     0\n",
       "v_2                     0\n",
       "v_3                     0\n",
       "v_4                     0\n",
       "v_5                     0\n",
       "v_6                     0\n",
       "v_7                     0\n",
       "v_8                     0\n",
       "v_9                     0\n",
       "v_10                    0\n",
       "v_11                    0\n",
       "v_12                    0\n",
       "v_13                    0\n",
       "v_14                    0\n",
       "dtype: int64"
      ]
     },
     "execution_count": 111,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 查看数据的缺失值\n",
    "train_data.isnull().sum()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 112,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "((150000, 31), (50000, 30))"
      ]
     },
     "execution_count": 112,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "train_data.shape,test_data.shape"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 113,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Index(['SaleID', 'name', 'regDate', 'model', 'brand', 'bodyType', 'fuelType',\n",
       "       'gearbox', 'power', 'kilometer', 'notRepairedDamage', 'regionCode',\n",
       "       'seller', 'offerType', 'creatDate', 'price', 'v_0', 'v_1', 'v_2', 'v_3',\n",
       "       'v_4', 'v_5', 'v_6', 'v_7', 'v_8', 'v_9', 'v_10', 'v_11', 'v_12',\n",
       "       'v_13', 'v_14'],\n",
       "      dtype='object')"
      ]
     },
     "execution_count": 113,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 找到数值类型的特征\n",
    "numerical_cols = train_data.select_dtypes(exclude='object').columns\n",
    "numerical_cols"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 114,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Index([], dtype='object')"
      ]
     },
     "execution_count": 114,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "object_cols = train_data.select_dtypes(include='object').columns\n",
    "object_cols"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 115,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['name',\n",
       " 'regDate',\n",
       " 'model',\n",
       " 'brand',\n",
       " 'bodyType',\n",
       " 'fuelType',\n",
       " 'gearbox',\n",
       " 'power',\n",
       " 'kilometer',\n",
       " 'notRepairedDamage',\n",
       " 'regionCode',\n",
       " 'seller',\n",
       " 'offerType',\n",
       " 'creatDate',\n",
       " 'v_0',\n",
       " 'v_1',\n",
       " 'v_2',\n",
       " 'v_3',\n",
       " 'v_4',\n",
       " 'v_5',\n",
       " 'v_6',\n",
       " 'v_7',\n",
       " 'v_8',\n",
       " 'v_9',\n",
       " 'v_10',\n",
       " 'v_11',\n",
       " 'v_12',\n",
       " 'v_13',\n",
       " 'v_14']"
      ]
     },
     "execution_count": 115,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "feature_cols = [col for col in numerical_cols if col not in ['SaleID','price']]\n",
    "feature_cols"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 116,
   "metadata": {},
   "outputs": [],
   "source": [
    "# feature_cols_test = [col for col in numerical_cols if col not in ['SaleID','price','regTime','creatTime','usedTime']]\n",
    "# feature_cols_test"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 117,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>SaleID</th>\n",
       "      <th>name</th>\n",
       "      <th>regDate</th>\n",
       "      <th>model</th>\n",
       "      <th>brand</th>\n",
       "      <th>bodyType</th>\n",
       "      <th>fuelType</th>\n",
       "      <th>gearbox</th>\n",
       "      <th>power</th>\n",
       "      <th>kilometer</th>\n",
       "      <th>...</th>\n",
       "      <th>v_5</th>\n",
       "      <th>v_6</th>\n",
       "      <th>v_7</th>\n",
       "      <th>v_8</th>\n",
       "      <th>v_9</th>\n",
       "      <th>v_10</th>\n",
       "      <th>v_11</th>\n",
       "      <th>v_12</th>\n",
       "      <th>v_13</th>\n",
       "      <th>v_14</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>0</td>\n",
       "      <td>736</td>\n",
       "      <td>20040402</td>\n",
       "      <td>30.0</td>\n",
       "      <td>6</td>\n",
       "      <td>1.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>60</td>\n",
       "      <td>12.5</td>\n",
       "      <td>...</td>\n",
       "      <td>0.235676</td>\n",
       "      <td>0.101988</td>\n",
       "      <td>0.129549</td>\n",
       "      <td>0.022816</td>\n",
       "      <td>0.097462</td>\n",
       "      <td>-2.881803</td>\n",
       "      <td>2.804097</td>\n",
       "      <td>-2.420821</td>\n",
       "      <td>0.795292</td>\n",
       "      <td>0.914762</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>1</td>\n",
       "      <td>2262</td>\n",
       "      <td>20030301</td>\n",
       "      <td>40.0</td>\n",
       "      <td>1</td>\n",
       "      <td>2.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0</td>\n",
       "      <td>15.0</td>\n",
       "      <td>...</td>\n",
       "      <td>0.264777</td>\n",
       "      <td>0.121004</td>\n",
       "      <td>0.135731</td>\n",
       "      <td>0.026597</td>\n",
       "      <td>0.020582</td>\n",
       "      <td>-4.900482</td>\n",
       "      <td>2.096338</td>\n",
       "      <td>-1.030483</td>\n",
       "      <td>-1.722674</td>\n",
       "      <td>0.245522</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>2</td>\n",
       "      <td>14874</td>\n",
       "      <td>20040403</td>\n",
       "      <td>115.0</td>\n",
       "      <td>15</td>\n",
       "      <td>1.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>163</td>\n",
       "      <td>12.5</td>\n",
       "      <td>...</td>\n",
       "      <td>0.251410</td>\n",
       "      <td>0.114912</td>\n",
       "      <td>0.165147</td>\n",
       "      <td>0.062173</td>\n",
       "      <td>0.027075</td>\n",
       "      <td>-4.846749</td>\n",
       "      <td>1.803559</td>\n",
       "      <td>1.565330</td>\n",
       "      <td>-0.832687</td>\n",
       "      <td>-0.229963</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>3</td>\n",
       "      <td>71865</td>\n",
       "      <td>19960908</td>\n",
       "      <td>109.0</td>\n",
       "      <td>10</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>193</td>\n",
       "      <td>15.0</td>\n",
       "      <td>...</td>\n",
       "      <td>0.274293</td>\n",
       "      <td>0.110300</td>\n",
       "      <td>0.121964</td>\n",
       "      <td>0.033395</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>-4.509599</td>\n",
       "      <td>1.285940</td>\n",
       "      <td>-0.501868</td>\n",
       "      <td>-2.438353</td>\n",
       "      <td>-0.478699</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>4</td>\n",
       "      <td>111080</td>\n",
       "      <td>20120103</td>\n",
       "      <td>110.0</td>\n",
       "      <td>5</td>\n",
       "      <td>1.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>68</td>\n",
       "      <td>5.0</td>\n",
       "      <td>...</td>\n",
       "      <td>0.228036</td>\n",
       "      <td>0.073205</td>\n",
       "      <td>0.091880</td>\n",
       "      <td>0.078819</td>\n",
       "      <td>0.121534</td>\n",
       "      <td>-1.896240</td>\n",
       "      <td>0.910783</td>\n",
       "      <td>0.931110</td>\n",
       "      <td>2.834518</td>\n",
       "      <td>1.923482</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>149995</th>\n",
       "      <td>149995</td>\n",
       "      <td>163978</td>\n",
       "      <td>20000607</td>\n",
       "      <td>121.0</td>\n",
       "      <td>10</td>\n",
       "      <td>4.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>163</td>\n",
       "      <td>15.0</td>\n",
       "      <td>...</td>\n",
       "      <td>0.280264</td>\n",
       "      <td>0.000310</td>\n",
       "      <td>0.048441</td>\n",
       "      <td>0.071158</td>\n",
       "      <td>0.019174</td>\n",
       "      <td>1.988114</td>\n",
       "      <td>-2.983973</td>\n",
       "      <td>0.589167</td>\n",
       "      <td>-1.304370</td>\n",
       "      <td>-0.302592</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>149996</th>\n",
       "      <td>149996</td>\n",
       "      <td>184535</td>\n",
       "      <td>20091102</td>\n",
       "      <td>116.0</td>\n",
       "      <td>11</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>125</td>\n",
       "      <td>10.0</td>\n",
       "      <td>...</td>\n",
       "      <td>0.253217</td>\n",
       "      <td>0.000777</td>\n",
       "      <td>0.084079</td>\n",
       "      <td>0.099681</td>\n",
       "      <td>0.079371</td>\n",
       "      <td>1.839166</td>\n",
       "      <td>-2.774615</td>\n",
       "      <td>2.553994</td>\n",
       "      <td>0.924196</td>\n",
       "      <td>-0.272160</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>149997</th>\n",
       "      <td>149997</td>\n",
       "      <td>147587</td>\n",
       "      <td>20101003</td>\n",
       "      <td>60.0</td>\n",
       "      <td>11</td>\n",
       "      <td>1.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>90</td>\n",
       "      <td>6.0</td>\n",
       "      <td>...</td>\n",
       "      <td>0.233353</td>\n",
       "      <td>0.000705</td>\n",
       "      <td>0.118872</td>\n",
       "      <td>0.100118</td>\n",
       "      <td>0.097914</td>\n",
       "      <td>2.439812</td>\n",
       "      <td>-1.630677</td>\n",
       "      <td>2.290197</td>\n",
       "      <td>1.891922</td>\n",
       "      <td>0.414931</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>149998</th>\n",
       "      <td>149998</td>\n",
       "      <td>45907</td>\n",
       "      <td>20060312</td>\n",
       "      <td>34.0</td>\n",
       "      <td>10</td>\n",
       "      <td>3.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>156</td>\n",
       "      <td>15.0</td>\n",
       "      <td>...</td>\n",
       "      <td>0.256369</td>\n",
       "      <td>0.000252</td>\n",
       "      <td>0.081479</td>\n",
       "      <td>0.083558</td>\n",
       "      <td>0.081498</td>\n",
       "      <td>2.075380</td>\n",
       "      <td>-2.633719</td>\n",
       "      <td>1.414937</td>\n",
       "      <td>0.431981</td>\n",
       "      <td>-1.659014</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>149999</th>\n",
       "      <td>149999</td>\n",
       "      <td>177672</td>\n",
       "      <td>19990204</td>\n",
       "      <td>19.0</td>\n",
       "      <td>28</td>\n",
       "      <td>6.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>193</td>\n",
       "      <td>12.5</td>\n",
       "      <td>...</td>\n",
       "      <td>0.284475</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.040072</td>\n",
       "      <td>0.062543</td>\n",
       "      <td>0.025819</td>\n",
       "      <td>1.978453</td>\n",
       "      <td>-3.179913</td>\n",
       "      <td>0.031724</td>\n",
       "      <td>-1.483350</td>\n",
       "      <td>-0.342674</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>150000 rows × 31 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "        SaleID    name   regDate  model  brand  bodyType  fuelType  gearbox  \\\n",
       "0            0     736  20040402   30.0      6       1.0       0.0      0.0   \n",
       "1            1    2262  20030301   40.0      1       2.0       0.0      0.0   \n",
       "2            2   14874  20040403  115.0     15       1.0       0.0      0.0   \n",
       "3            3   71865  19960908  109.0     10       0.0       0.0      1.0   \n",
       "4            4  111080  20120103  110.0      5       1.0       0.0      0.0   \n",
       "...        ...     ...       ...    ...    ...       ...       ...      ...   \n",
       "149995  149995  163978  20000607  121.0     10       4.0       0.0      1.0   \n",
       "149996  149996  184535  20091102  116.0     11       0.0       0.0      0.0   \n",
       "149997  149997  147587  20101003   60.0     11       1.0       1.0      0.0   \n",
       "149998  149998   45907  20060312   34.0     10       3.0       1.0      0.0   \n",
       "149999  149999  177672  19990204   19.0     28       6.0       0.0      1.0   \n",
       "\n",
       "        power  kilometer  ...       v_5       v_6       v_7       v_8  \\\n",
       "0          60       12.5  ...  0.235676  0.101988  0.129549  0.022816   \n",
       "1           0       15.0  ...  0.264777  0.121004  0.135731  0.026597   \n",
       "2         163       12.5  ...  0.251410  0.114912  0.165147  0.062173   \n",
       "3         193       15.0  ...  0.274293  0.110300  0.121964  0.033395   \n",
       "4          68        5.0  ...  0.228036  0.073205  0.091880  0.078819   \n",
       "...       ...        ...  ...       ...       ...       ...       ...   \n",
       "149995    163       15.0  ...  0.280264  0.000310  0.048441  0.071158   \n",
       "149996    125       10.0  ...  0.253217  0.000777  0.084079  0.099681   \n",
       "149997     90        6.0  ...  0.233353  0.000705  0.118872  0.100118   \n",
       "149998    156       15.0  ...  0.256369  0.000252  0.081479  0.083558   \n",
       "149999    193       12.5  ...  0.284475  0.000000  0.040072  0.062543   \n",
       "\n",
       "             v_9      v_10      v_11      v_12      v_13      v_14  \n",
       "0       0.097462 -2.881803  2.804097 -2.420821  0.795292  0.914762  \n",
       "1       0.020582 -4.900482  2.096338 -1.030483 -1.722674  0.245522  \n",
       "2       0.027075 -4.846749  1.803559  1.565330 -0.832687 -0.229963  \n",
       "3       0.000000 -4.509599  1.285940 -0.501868 -2.438353 -0.478699  \n",
       "4       0.121534 -1.896240  0.910783  0.931110  2.834518  1.923482  \n",
       "...          ...       ...       ...       ...       ...       ...  \n",
       "149995  0.019174  1.988114 -2.983973  0.589167 -1.304370 -0.302592  \n",
       "149996  0.079371  1.839166 -2.774615  2.553994  0.924196 -0.272160  \n",
       "149997  0.097914  2.439812 -1.630677  2.290197  1.891922  0.414931  \n",
       "149998  0.081498  2.075380 -2.633719  1.414937  0.431981 -1.659014  \n",
       "149999  0.025819  1.978453 -3.179913  0.031724 -1.483350 -0.342674  \n",
       "\n",
       "[150000 rows x 31 columns]"
      ]
     },
     "execution_count": 117,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "train_data"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 118,
   "metadata": {},
   "outputs": [],
   "source": [
    "# 提取特征列\n",
    "X_data = train_data[feature_cols]\n",
    "Y_data = train_data['price']\n",
    "X_test = test_data[feature_cols]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 119,
   "metadata": {},
   "outputs": [],
   "source": [
    "# 定义统计函数，方便了解数据分布\n",
    "def show_stats(data):\n",
    "    print('min',np.min(data))\n",
    "    print('max',np.max(data))\n",
    "    print('最小值减最大值',np.ptp(data)) \n",
    "    print('mean',np.mean(data))\n",
    "    print('标准差std',np.std(data))\n",
    "    print('方差var',np.var(data))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 120,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "min 11\n",
      "max 99999\n",
      "最小值减最大值 99988\n",
      "mean 5923.327333333334\n",
      "标准差std 7501.973469876635\n",
      "方差var 56279605.942732885\n"
     ]
    }
   ],
   "source": [
    "# 训练集中的price\n",
    "show_stats(Y_data)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 121,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "name                    0\n",
       "regDate                 0\n",
       "model                   1\n",
       "brand                   0\n",
       "bodyType             4506\n",
       "fuelType             8680\n",
       "gearbox              5981\n",
       "power                   0\n",
       "kilometer               0\n",
       "notRepairedDamage       0\n",
       "regionCode              0\n",
       "seller                  0\n",
       "offerType               0\n",
       "creatDate               0\n",
       "v_0                     0\n",
       "v_1                     0\n",
       "v_2                     0\n",
       "v_3                     0\n",
       "v_4                     0\n",
       "v_5                     0\n",
       "v_6                     0\n",
       "v_7                     0\n",
       "v_8                     0\n",
       "v_9                     0\n",
       "v_10                    0\n",
       "v_11                    0\n",
       "v_12                    0\n",
       "v_13                    0\n",
       "v_14                    0\n",
       "dtype: int64"
      ]
     },
     "execution_count": 121,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "X_data.isnull().sum()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 122,
   "metadata": {},
   "outputs": [],
   "source": [
    "# 缺失值用-1补全\n",
    "X_data = X_data.fillna(-1)\n",
    "X_test = X_test.fillna(-1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 123,
   "metadata": {},
   "outputs": [],
   "source": [
    "# 欠拟合结果\n",
    "# import xgboost as xgb\n",
    "# model = xgb.XGBRegressor(n_estimators=500, learning_rate=0.01, max_depth=7)\n",
    "# model.fit(X_data, Y_data)\n",
    "# predict_y = model.predict(X_test)\n",
    "# print(\"XGBoost预测结果统计情况：\")\n",
    "# show_stats(predict_y)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 124,
   "metadata": {},
   "outputs": [],
   "source": [
    "# 输出结果\n",
    "# result = pd.DataFrame()\n",
    "# result['SaleID'] = test_data['SaleID']\n",
    "# result['price'] = predict_y\n",
    "# result.loc[result['price']<11] = 11 # 用.loc方法赋值才可以\n",
    "# result.to_csv('./ans_xgb.csv', index=False)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 125,
   "metadata": {},
   "outputs": [],
   "source": [
    "# 为了验证模型，对原数据进行分批，以计算模型的mae\n",
    "# xgboost,lightGBM 两个模型融合，相加除以2\n",
    "from sklearn.model_selection import train_test_split, GridSearchCV\n",
    "x_train, x_val, y_train, y_val = train_test_split(X_data, Y_data, test_size=0.2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 126,
   "metadata": {},
   "outputs": [],
   "source": [
    "def build_model_xgb(x_train, y_train):\n",
    "    model = xgb.XGBRegressor(n_estimators=150, learning=0.1, max_depth=7)\n",
    "    model.fit(x_train, y_train)\n",
    "    return model\n",
    "\n",
    "import lightgbm as lgb\n",
    "def build_model_lgb(x_train, y_train):\n",
    "    estimator = lgb.LGBMRegressor(n_estimators=150, num_leaves=127)\n",
    "    # 设置超参数范围，对超参数进行网格搜索\n",
    "    param_grid = {'learning_rate':[0.01, 0.05, 0.1, 0.2]}\n",
    "    model = GridSearchCV(estimator, param_grid)\n",
    "    model.fit(x_train, y_train)\n",
    "    return model"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 128,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[13:14:16] WARNING: C:\\Users\\Administrator\\workspace\\xgboost-win64_release_1.1.0\\src\\learner.cc:480: \n",
      "Parameters: { learning } might not be used.\n",
      "\n",
      "  This may not be accurate due to some parameters are only used in language bindings but\n",
      "  passed down to XGBoost core.  Or some parameters are not used but slip through this\n",
      "  verification. Please open an issue if you find above cases.\n",
      "\n",
      "\n",
      "xgb validation MAE: 605.8530661772967\n",
      "[13:14:53] WARNING: C:\\Users\\Administrator\\workspace\\xgboost-win64_release_1.1.0\\src\\learner.cc:480: \n",
      "Parameters: { learning } might not be used.\n",
      "\n",
      "  This may not be accurate due to some parameters are only used in language bindings but\n",
      "  passed down to XGBoost core.  Or some parameters are not used but slip through this\n",
      "  verification. Please open an issue if you find above cases.\n",
      "\n",
      "\n",
      "XGBoost预测结果统计情况：\n",
      "min -864.3164\n",
      "max 94322.59\n",
      "最小值减最大值 95186.91\n",
      "mean 5906.6387\n",
      "标准差std 7374.3193\n",
      "方差var 54380584.0\n"
     ]
    }
   ],
   "source": [
    "from sklearn.metrics import mean_absolute_error\n",
    "# xgb\n",
    "model_xgb = build_model_xgb(x_train, y_train)\n",
    "val_xgb = model_xgb.predict(x_val)\n",
    "MAE_xgb = mean_absolute_error(y_val, val_xgb)\n",
    "print('xgb validation MAE:', MAE_xgb)\n",
    "# 全量数据\n",
    "model_xgb2 = build_model_xgb(X_data, Y_data)\n",
    "result_xgb = model_xgb2.predict(X_test)\n",
    "print(\"XGBoost预测结果统计情况：\")\n",
    "show_stats(result_xgb)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 129,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "lgb validation MAE: 574.5142108928364\n",
      "XGBoost预测结果统计情况：\n",
      "min -785.5819234940341\n",
      "max 90698.94650635302\n",
      "最小值减最大值 91484.52842984705\n",
      "mean 5906.21916371564\n",
      "标准差std 7359.909752864445\n",
      "方差var 54168271.57030918\n"
     ]
    }
   ],
   "source": [
    "# lgb训练\n",
    "model_lgb = build_model_lgb(x_train, y_train)\n",
    "val_lgb = model_lgb.predict(x_val)\n",
    "MAE_lgb = mean_absolute_error(y_val, val_lgb)\n",
    "print('lgb validation MAE:', MAE_lgb)\n",
    "# 全量数据\n",
    "model_lgb = build_model_lgb(X_data, Y_data)\n",
    "result_lgb = model_lgb.predict(X_test)\n",
    "print(\"lgb预测结果统计情况：\")\n",
    "show_stats(result_lgb)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 130,
   "metadata": {},
   "outputs": [],
   "source": [
    "# 通过MAE的比重对lgb和xgb加权融合\n",
    "# 1-意思是谁的mae小，就用谁的融合的权重大\n",
    "predict_y = (1-MAE_lgb/(MAE_xgb+MAE_lgb))*result_lgb + (1-MAE_xgb/(MAE_xgb+MAE_lgb))*result_xgb"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 139,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "LGB权重： 0.5132750440872305\n",
      "XGB权重： 0.48672495591276965\n"
     ]
    }
   ],
   "source": [
    "print('LGB权重：', 1-MAE_lgb/(MAE_xgb+MAE_lgb))\n",
    "print('XGB权重：', 1-MAE_xgb/(MAE_xgb+MAE_lgb))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 132,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([1333.32214134, 1851.4280896 , 8375.46578101, ..., 5701.89289354,\n",
       "       5129.35396464, 5553.00430142])"
      ]
     },
     "execution_count": 132,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "predict_y"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 146,
   "metadata": {},
   "outputs": [],
   "source": [
    "# 输出结果\n",
    "result = pd.DataFrame()\n",
    "result['SaleID'] = sample_data['SaleID']\n",
    "result['price'] = predict_y\n",
    "result.loc[result['price']<11, 'price'] = 11 # 用.loc方法赋值才可以"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "result.loc[result['price']<11, 'price'] = 11 # 正确\n",
    "result.loc[result['price']<11] = 11 # 错误"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 148,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "min 11.0\n",
      "max 92133.6878682676\n",
      "最小值减最大值 92122.6878682676\n",
      "mean 5906.550073150059\n",
      "标准差std 7357.8002743784855\n",
      "方差var 54137224.877644114\n"
     ]
    }
   ],
   "source": [
    "show_stats(result.price)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 147,
   "metadata": {
    "collapsed": true,
    "jupyter": {
     "outputs_hidden": true
    }
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>SaleID</th>\n",
       "      <th>price</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>1217</th>\n",
       "      <td>151217</td>\n",
       "      <td>11.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2052</th>\n",
       "      <td>152052</td>\n",
       "      <td>11.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2435</th>\n",
       "      <td>152435</td>\n",
       "      <td>11.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5726</th>\n",
       "      <td>155726</td>\n",
       "      <td>11.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9618</th>\n",
       "      <td>159618</td>\n",
       "      <td>11.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9773</th>\n",
       "      <td>159773</td>\n",
       "      <td>11.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>11127</th>\n",
       "      <td>161127</td>\n",
       "      <td>11.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>11465</th>\n",
       "      <td>161465</td>\n",
       "      <td>11.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>12924</th>\n",
       "      <td>162924</td>\n",
       "      <td>11.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>17751</th>\n",
       "      <td>167751</td>\n",
       "      <td>11.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>17826</th>\n",
       "      <td>167826</td>\n",
       "      <td>11.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>19316</th>\n",
       "      <td>169316</td>\n",
       "      <td>11.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>19582</th>\n",
       "      <td>169582</td>\n",
       "      <td>11.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>21313</th>\n",
       "      <td>171313</td>\n",
       "      <td>11.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>21750</th>\n",
       "      <td>171750</td>\n",
       "      <td>11.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>22172</th>\n",
       "      <td>172172</td>\n",
       "      <td>11.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>23079</th>\n",
       "      <td>173079</td>\n",
       "      <td>11.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>23615</th>\n",
       "      <td>173615</td>\n",
       "      <td>11.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>23942</th>\n",
       "      <td>173942</td>\n",
       "      <td>11.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>24339</th>\n",
       "      <td>174339</td>\n",
       "      <td>11.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>24494</th>\n",
       "      <td>174494</td>\n",
       "      <td>11.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>26712</th>\n",
       "      <td>176712</td>\n",
       "      <td>11.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>27150</th>\n",
       "      <td>177150</td>\n",
       "      <td>11.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>27521</th>\n",
       "      <td>177521</td>\n",
       "      <td>11.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>28402</th>\n",
       "      <td>178402</td>\n",
       "      <td>11.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>31751</th>\n",
       "      <td>181751</td>\n",
       "      <td>11.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>32501</th>\n",
       "      <td>182501</td>\n",
       "      <td>11.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>34338</th>\n",
       "      <td>184338</td>\n",
       "      <td>11.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>38290</th>\n",
       "      <td>188290</td>\n",
       "      <td>11.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>40217</th>\n",
       "      <td>190217</td>\n",
       "      <td>11.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>40579</th>\n",
       "      <td>190579</td>\n",
       "      <td>11.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>40644</th>\n",
       "      <td>190644</td>\n",
       "      <td>11.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>41702</th>\n",
       "      <td>191702</td>\n",
       "      <td>11.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>46194</th>\n",
       "      <td>196194</td>\n",
       "      <td>11.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>47027</th>\n",
       "      <td>197027</td>\n",
       "      <td>11.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>49849</th>\n",
       "      <td>199849</td>\n",
       "      <td>11.0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "       SaleID  price\n",
       "1217   151217   11.0\n",
       "2052   152052   11.0\n",
       "2435   152435   11.0\n",
       "5726   155726   11.0\n",
       "9618   159618   11.0\n",
       "9773   159773   11.0\n",
       "11127  161127   11.0\n",
       "11465  161465   11.0\n",
       "12924  162924   11.0\n",
       "17751  167751   11.0\n",
       "17826  167826   11.0\n",
       "19316  169316   11.0\n",
       "19582  169582   11.0\n",
       "21313  171313   11.0\n",
       "21750  171750   11.0\n",
       "22172  172172   11.0\n",
       "23079  173079   11.0\n",
       "23615  173615   11.0\n",
       "23942  173942   11.0\n",
       "24339  174339   11.0\n",
       "24494  174494   11.0\n",
       "26712  176712   11.0\n",
       "27150  177150   11.0\n",
       "27521  177521   11.0\n",
       "28402  178402   11.0\n",
       "31751  181751   11.0\n",
       "32501  182501   11.0\n",
       "34338  184338   11.0\n",
       "38290  188290   11.0\n",
       "40217  190217   11.0\n",
       "40579  190579   11.0\n",
       "40644  190644   11.0\n",
       "41702  191702   11.0\n",
       "46194  196194   11.0\n",
       "47027  197027   11.0\n",
       "49849  199849   11.0"
      ]
     },
     "execution_count": 147,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "result[result['price']==11]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 149,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "min 11.0\n",
      "max 92133.6878682676\n",
      "最小值减最大值 92122.6878682676\n",
      "mean 5906.550073150059\n",
      "标准差std 7357.8002743784855\n",
      "方差var 54137224.877644114\n"
     ]
    }
   ],
   "source": [
    "show_stats(result.price)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 150,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>SaleID</th>\n",
       "      <th>price</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>count</th>\n",
       "      <td>50000.000000</td>\n",
       "      <td>50000.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>mean</th>\n",
       "      <td>174999.500000</td>\n",
       "      <td>5906.550073</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>std</th>\n",
       "      <td>14433.901067</td>\n",
       "      <td>7357.873853</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>min</th>\n",
       "      <td>150000.000000</td>\n",
       "      <td>11.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>25%</th>\n",
       "      <td>162499.750000</td>\n",
       "      <td>1380.822808</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>50%</th>\n",
       "      <td>174999.500000</td>\n",
       "      <td>3246.707579</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>75%</th>\n",
       "      <td>187499.250000</td>\n",
       "      <td>7631.841200</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>max</th>\n",
       "      <td>199999.000000</td>\n",
       "      <td>92133.687868</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "              SaleID         price\n",
       "count   50000.000000  50000.000000\n",
       "mean   174999.500000   5906.550073\n",
       "std     14433.901067   7357.873853\n",
       "min    150000.000000     11.000000\n",
       "25%    162499.750000   1380.822808\n",
       "50%    174999.500000   3246.707579\n",
       "75%    187499.250000   7631.841200\n",
       "max    199999.000000  92133.687868"
      ]
     },
     "execution_count": 150,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "result.describe()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 152,
   "metadata": {},
   "outputs": [],
   "source": [
    "result.to_csv('./lgb_xgb.csv', index=False)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# keras搭建神经网络"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 177,
   "metadata": {},
   "outputs": [],
   "source": [
    "# 对X_data和X_test进行归一化\n",
    "from sklearn.preprocessing import MinMaxScaler\n",
    "scaler = MinMaxScaler()\n",
    "x = scaler.fit_transform(X_data.values)\n",
    "y = Y_data\n",
    "X_test = scaler.fit_transform(X_test)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 158,
   "metadata": {},
   "outputs": [],
   "source": [
    "# 非全量数据进行模型选型调试\n",
    "from sklearn.model_selection import train_test_split\n",
    "x_train, x_test, y_train, y_test = train_test_split(x, y, test_size = 0.2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 192,
   "metadata": {
    "collapsed": true,
    "jupyter": {
     "outputs_hidden": true
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Epoch 1/100\n",
      "118/118 [==============================] - 1s 12ms/step - loss: 4929.2461 - val_loss: 4059.2163\n",
      "Epoch 2/100\n",
      "118/118 [==============================] - 1s 9ms/step - loss: 2915.0964 - val_loss: 1575.0320\n",
      "Epoch 3/100\n",
      "118/118 [==============================] - 1s 9ms/step - loss: 1363.0376 - val_loss: 1223.8140\n",
      "Epoch 4/100\n",
      "118/118 [==============================] - 1s 9ms/step - loss: 1147.8062 - val_loss: 1070.0308\n",
      "Epoch 5/100\n",
      "118/118 [==============================] - 1s 9ms/step - loss: 1034.6555 - val_loss: 982.0693\n",
      "Epoch 6/100\n",
      "118/118 [==============================] - 1s 9ms/step - loss: 955.8211 - val_loss: 919.5361\n",
      "Epoch 7/100\n",
      "118/118 [==============================] - 1s 9ms/step - loss: 903.4585 - val_loss: 873.4995\n",
      "Epoch 8/100\n",
      "118/118 [==============================] - 1s 8ms/step - loss: 861.8434 - val_loss: 848.1775\n",
      "Epoch 9/100\n",
      "118/118 [==============================] - 1s 9ms/step - loss: 829.6898 - val_loss: 812.7255\n",
      "Epoch 10/100\n",
      "118/118 [==============================] - 1s 9ms/step - loss: 805.5602 - val_loss: 791.0340\n",
      "Epoch 11/100\n",
      "118/118 [==============================] - 1s 9ms/step - loss: 783.2964 - val_loss: 772.0295\n",
      "Epoch 12/100\n",
      "118/118 [==============================] - 1s 10ms/step - loss: 764.9174 - val_loss: 764.3871\n",
      "Epoch 13/100\n",
      "118/118 [==============================] - 1s 10ms/step - loss: 753.2495 - val_loss: 767.7261\n",
      "Epoch 14/100\n",
      "118/118 [==============================] - 1s 9ms/step - loss: 745.3592 - val_loss: 734.9935\n",
      "Epoch 15/100\n",
      "118/118 [==============================] - 1s 8ms/step - loss: 728.6340 - val_loss: 728.6366\n",
      "Epoch 16/100\n",
      "118/118 [==============================] - 1s 9ms/step - loss: 718.0677 - val_loss: 716.5357\n",
      "Epoch 17/100\n",
      "118/118 [==============================] - 1s 9ms/step - loss: 708.8480 - val_loss: 712.6027\n",
      "Epoch 18/100\n",
      "118/118 [==============================] - 1s 9ms/step - loss: 705.0490 - val_loss: 702.0091\n",
      "Epoch 19/100\n",
      "118/118 [==============================] - 1s 9ms/step - loss: 692.8900 - val_loss: 700.5436\n",
      "Epoch 20/100\n",
      "118/118 [==============================] - 1s 9ms/step - loss: 687.8112 - val_loss: 688.6484\n",
      "Epoch 21/100\n",
      "118/118 [==============================] - 1s 8ms/step - loss: 680.1459 - val_loss: 683.4500\n",
      "Epoch 22/100\n",
      "118/118 [==============================] - 1s 8ms/step - loss: 673.2789 - val_loss: 676.5565\n",
      "Epoch 23/100\n",
      "118/118 [==============================] - 1s 9ms/step - loss: 665.3820 - val_loss: 666.9915\n",
      "Epoch 24/100\n",
      "118/118 [==============================] - 1s 9ms/step - loss: 659.0180 - val_loss: 670.3312\n",
      "Epoch 25/100\n",
      "118/118 [==============================] - 1s 9ms/step - loss: 654.7601 - val_loss: 653.1880\n",
      "Epoch 26/100\n",
      "118/118 [==============================] - 1s 9ms/step - loss: 647.1422 - val_loss: 647.2769\n",
      "Epoch 27/100\n",
      "118/118 [==============================] - 1s 9ms/step - loss: 638.9478 - val_loss: 656.4022\n",
      "Epoch 28/100\n",
      "118/118 [==============================] - 1s 9ms/step - loss: 631.3757 - val_loss: 632.1843\n",
      "Epoch 29/100\n",
      "118/118 [==============================] - 1s 9ms/step - loss: 624.7207 - val_loss: 626.9222\n",
      "Epoch 30/100\n",
      "118/118 [==============================] - 1s 9ms/step - loss: 617.8340 - val_loss: 620.7496\n",
      "Epoch 31/100\n",
      "118/118 [==============================] - 1s 9ms/step - loss: 612.5518 - val_loss: 625.0182\n",
      "Epoch 32/100\n",
      "118/118 [==============================] - 1s 9ms/step - loss: 606.1290 - val_loss: 606.6428\n",
      "Epoch 33/100\n",
      "118/118 [==============================] - 1s 9ms/step - loss: 597.8083 - val_loss: 613.5029\n",
      "Epoch 34/100\n",
      "118/118 [==============================] - 1s 8ms/step - loss: 594.8983 - val_loss: 602.9038\n",
      "Epoch 35/100\n",
      "118/118 [==============================] - 1s 8ms/step - loss: 589.1884 - val_loss: 625.3687\n",
      "Epoch 36/100\n",
      "118/118 [==============================] - 1s 9ms/step - loss: 584.7939 - val_loss: 590.4081\n",
      "Epoch 37/100\n",
      "118/118 [==============================] - 1s 9ms/step - loss: 579.4099 - val_loss: 589.8350\n",
      "Epoch 38/100\n",
      "118/118 [==============================] - 1s 10ms/step - loss: 577.9482 - val_loss: 586.0089\n",
      "Epoch 39/100\n",
      "118/118 [==============================] - 1s 9ms/step - loss: 573.6383 - val_loss: 583.1404\n",
      "Epoch 40/100\n",
      "118/118 [==============================] - 1s 9ms/step - loss: 573.9456 - val_loss: 574.4388\n",
      "Epoch 41/100\n",
      "118/118 [==============================] - 1s 9ms/step - loss: 568.4349 - val_loss: 578.8561\n",
      "Epoch 42/100\n",
      "118/118 [==============================] - 1s 9ms/step - loss: 567.8105 - val_loss: 578.7587\n",
      "Epoch 43/100\n",
      "118/118 [==============================] - 1s 9ms/step - loss: 564.8204 - val_loss: 577.5986\n",
      "Epoch 44/100\n",
      "118/118 [==============================] - 1s 9ms/step - loss: 561.0452 - val_loss: 574.9239\n",
      "Epoch 45/100\n",
      "118/118 [==============================] - 1s 9ms/step - loss: 565.4714 - val_loss: 596.6720\n",
      "Epoch 46/100\n",
      "118/118 [==============================] - 1s 9ms/step - loss: 559.1924 - val_loss: 565.8338\n",
      "Epoch 47/100\n",
      "118/118 [==============================] - 1s 9ms/step - loss: 557.1340 - val_loss: 565.9274\n",
      "Epoch 48/100\n",
      "118/118 [==============================] - 1s 9ms/step - loss: 555.0402 - val_loss: 570.4858\n",
      "Epoch 49/100\n",
      "118/118 [==============================] - 1s 9ms/step - loss: 552.8293 - val_loss: 572.1892\n",
      "Epoch 50/100\n",
      "118/118 [==============================] - 1s 9ms/step - loss: 554.2046 - val_loss: 563.4522\n",
      "Epoch 51/100\n",
      "118/118 [==============================] - 1s 9ms/step - loss: 551.1316 - val_loss: 558.8083\n",
      "Epoch 52/100\n",
      "118/118 [==============================] - 1s 9ms/step - loss: 550.5942 - val_loss: 563.3909\n",
      "Epoch 53/100\n",
      "118/118 [==============================] - 1s 9ms/step - loss: 549.0951 - val_loss: 559.1514\n",
      "Epoch 54/100\n",
      "118/118 [==============================] - 1s 9ms/step - loss: 548.1942 - val_loss: 560.1768\n",
      "Epoch 55/100\n",
      "118/118 [==============================] - 1s 9ms/step - loss: 546.9761 - val_loss: 601.0361\n",
      "Epoch 56/100\n",
      "118/118 [==============================] - 1s 9ms/step - loss: 547.8763 - val_loss: 558.5423\n",
      "Epoch 57/100\n",
      "118/118 [==============================] - 1s 9ms/step - loss: 548.8278 - val_loss: 566.1994\n",
      "Epoch 58/100\n",
      "118/118 [==============================] - 1s 9ms/step - loss: 543.3462 - val_loss: 552.5723\n",
      "Epoch 59/100\n",
      "118/118 [==============================] - 1s 9ms/step - loss: 542.2296 - val_loss: 559.4282\n",
      "Epoch 60/100\n",
      "118/118 [==============================] - 1s 9ms/step - loss: 542.4844 - val_loss: 550.6729\n",
      "Epoch 61/100\n",
      "118/118 [==============================] - 1s 9ms/step - loss: 541.0808 - val_loss: 560.0151\n",
      "Epoch 62/100\n",
      "118/118 [==============================] - 1s 9ms/step - loss: 541.8918 - val_loss: 558.0513\n",
      "Epoch 63/100\n",
      "118/118 [==============================] - 1s 9ms/step - loss: 538.8769 - val_loss: 551.5726\n",
      "Epoch 64/100\n",
      "118/118 [==============================] - 1s 9ms/step - loss: 540.5912 - val_loss: 547.2954\n",
      "Epoch 65/100\n",
      "118/118 [==============================] - 1s 9ms/step - loss: 539.1202 - val_loss: 555.1957\n",
      "Epoch 66/100\n",
      "118/118 [==============================] - 1s 9ms/step - loss: 540.1895 - val_loss: 548.2518\n",
      "Epoch 67/100\n",
      "118/118 [==============================] - 1s 9ms/step - loss: 538.1959 - val_loss: 549.5465\n",
      "Epoch 68/100\n",
      "118/118 [==============================] - 1s 9ms/step - loss: 537.4909 - val_loss: 550.6202\n",
      "Epoch 69/100\n",
      "118/118 [==============================] - 1s 9ms/step - loss: 535.9498 - val_loss: 559.1672\n",
      "Epoch 70/100\n",
      "118/118 [==============================] - 1s 9ms/step - loss: 535.6307 - val_loss: 551.8157\n",
      "Epoch 71/100\n",
      "118/118 [==============================] - 1s 9ms/step - loss: 535.1490 - val_loss: 553.1148\n",
      "Epoch 72/100\n",
      "118/118 [==============================] - 1s 11ms/step - loss: 534.7340 - val_loss: 545.2289\n",
      "Epoch 73/100\n",
      "118/118 [==============================] - 1s 12ms/step - loss: 533.5642 - val_loss: 559.4347\n",
      "Epoch 74/100\n",
      "118/118 [==============================] - 1s 12ms/step - loss: 534.0119 - val_loss: 542.5056\n",
      "Epoch 75/100\n",
      "118/118 [==============================] - 1s 10ms/step - loss: 534.0345 - val_loss: 540.5721\n",
      "Epoch 76/100\n",
      "118/118 [==============================] - 1s 12ms/step - loss: 529.9651 - val_loss: 548.0174\n",
      "Epoch 77/100\n",
      "118/118 [==============================] - 1s 12ms/step - loss: 532.8122 - val_loss: 544.5008\n",
      "Epoch 78/100\n",
      "118/118 [==============================] - 1s 11ms/step - loss: 529.6475 - val_loss: 541.6665\n",
      "Epoch 79/100\n",
      "118/118 [==============================] - 1s 11ms/step - loss: 529.7567 - val_loss: 543.6934\n",
      "Epoch 80/100\n",
      "118/118 [==============================] - 1s 10ms/step - loss: 530.3007 - val_loss: 551.7621\n",
      "Epoch 81/100\n",
      "118/118 [==============================] - 1s 10ms/step - loss: 531.0992 - val_loss: 549.6678\n",
      "Epoch 82/100\n",
      "118/118 [==============================] - 1s 10ms/step - loss: 528.1367 - val_loss: 539.0510\n",
      "Epoch 83/100\n",
      "118/118 [==============================] - 1s 9ms/step - loss: 528.0121 - val_loss: 542.9020\n",
      "Epoch 84/100\n",
      "118/118 [==============================] - 1s 12ms/step - loss: 528.4499 - val_loss: 549.8293\n",
      "Epoch 85/100\n",
      "118/118 [==============================] - 2s 13ms/step - loss: 526.5863 - val_loss: 549.0475\n",
      "Epoch 86/100\n",
      "118/118 [==============================] - 1s 12ms/step - loss: 526.7131 - val_loss: 550.5370\n",
      "Epoch 87/100\n",
      "118/118 [==============================] - 1s 10ms/step - loss: 526.1812 - val_loss: 544.1260\n",
      "Epoch 88/100\n",
      "118/118 [==============================] - 1s 11ms/step - loss: 523.3409 - val_loss: 558.9323\n",
      "Epoch 89/100\n",
      "118/118 [==============================] - 1s 11ms/step - loss: 526.8796 - val_loss: 545.6473\n",
      "Epoch 90/100\n",
      "118/118 [==============================] - 1s 11ms/step - loss: 525.4193 - val_loss: 534.8987\n",
      "Epoch 91/100\n",
      "118/118 [==============================] - 1s 11ms/step - loss: 524.9514 - val_loss: 536.0693\n",
      "Epoch 92/100\n",
      "118/118 [==============================] - 1s 12ms/step - loss: 522.1744 - val_loss: 536.9686\n",
      "Epoch 93/100\n",
      "118/118 [==============================] - 1s 13ms/step - loss: 525.4708 - val_loss: 534.1793\n",
      "Epoch 94/100\n",
      "118/118 [==============================] - 1s 12ms/step - loss: 523.9784 - val_loss: 559.6605\n",
      "Epoch 95/100\n",
      "118/118 [==============================] - 1s 10ms/step - loss: 525.3745 - val_loss: 540.9478\n",
      "Epoch 96/100\n",
      "118/118 [==============================] - 1s 10ms/step - loss: 522.3909 - val_loss: 535.4233\n",
      "Epoch 97/100\n",
      "118/118 [==============================] - 1s 10ms/step - loss: 520.6937 - val_loss: 535.3289\n",
      "Epoch 98/100\n",
      "118/118 [==============================] - 1s 9ms/step - loss: 520.6151 - val_loss: 532.3088\n",
      "Epoch 99/100\n",
      "118/118 [==============================] - 1s 9ms/step - loss: 522.1693 - val_loss: 540.5858\n",
      "Epoch 100/100\n",
      "118/118 [==============================] - 1s 9ms/step - loss: 519.9596 - val_loss: 534.4771\n"
     ]
    }
   ],
   "source": [
    "from tensorflow import keras\n",
    "model=keras.Sequential([\n",
    "    keras.layers.Dense(250,activation='relu',input_shape=[len(feature_cols)]),\n",
    "    keras.layers.Dense(250,activation='relu'),\n",
    "    keras.layers.Dense(250,activation='relu'),\n",
    "    keras.layers.Dense(1)\n",
    "])\n",
    "model.compile(loss='mean_absolute_error',optimizer='Adam')\n",
    "history = model.fit(x_train,y_train,batch_size=1024, epochs=100, validation_data=(x_test, y_test), validation_freq=1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 193,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAX0AAAEICAYAAACzliQjAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjMuMCwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy86wFpk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XPrW79ayrqq+V7c5/sQSbv27CZ2+fuedd7JmzRreeOMNAJYtW8arr77KmjVr2k9HfOCBBxg0aBAtLS3MnDmTK664grKysv22s3HjRh599FF++tOf8qlPfYrf/OY3XHXVVYes329/+1veeOMNVq9eza5du5g5cyZz5szhl7/8JRdccAFf//rXyWazNDc388Ybb7B9+3bWrFkD0KOhpf4W2GkY8mIOSevpG3NcmzVr1n7nn999991MmTKF2bNns23bNjZu3HjQOqNHj2bq1KkATJ8+na1bt3brvf785z+zYMECHMdh6NChnH322axYsYKZM2fy85//nNtuu4233nqL4uJiTjrpJN555x2+/OUv89xzz1FSUtIbzT0qgtvTj0ZotTF9Yw5LVz3yo6mwsLD98bJly3jxxRd55ZVXKCgoYO7cuR2en55IJNofO47To+GdjsyZM4fly5fz9NNP89nPfpYbb7yRq6++mtWrV/P888/z4x//mMcee4wHHnigh63rH4Hu6duYvjHHj+LiYhoaGjp9fd++fZSWllJQUMDbb7/NX/7yl159/zlz5vCrX/2KbDZLbW0ty5cvZ9asWbz77rsMGTKE6667jmuvvZZVq1axa9cuXNfliiuu4Pbbb2fVqlW9Wpe+FNiefl4sQjJtPX1jjhdlZWWcccYZTJw4kYsuuoiPfexj+71+4YUX8pOf/ITJkyczbtw4Zs+efUTv953vfIcf/vCH7c+3bdvGK6+8wpQpUxARvve973HCCSewaNEivv/97xOLxSgqKuKhhx5i+/btfO5zn8N1vY7ld7/73SOqy9EkfXgCTa+YMWOGHs5FVG5/ah2LX32Ptd++sA9qZUzwrF+/ntNOO62/q2EOQ0d/OxF5TVVnHLhsgId3IrRmbHjHGGNyBTf0ow4ZV8lkLfiNMaZNYEM/EfOalrTevjHGtAts6OfFHAA7mGuMMTmCG/pRL/RtXN8YY94X2NBvH96xnr4xxrQLbuhHbXjHmOPJ3Llzef755/cr++EPf8g//MM/dLlO2yndnU2v3J1plJ944gnWrVvX/vyb3/wmL774Yg9q37Fly5ZxySWXHPF2elNgQz/P7+nb8I4xx4cFCxawePHi/coWL17Mgg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tcAswBfgagqilVrSPg7ca7pGu+iESBAqCKALZZVZcDew4o7qyd84DFqtqqqluATXi51y1BDP3hwLac55V+WaCJyCjgdOCvwFBVrQZvxwAM6ceq9YUfAv8CuDllQW/zSUAt8HN/WOt+ESkkwO1W1e3AXcB7QDWwT1V/T4DbfIDO2nlEGRfE0O/oCs2BPi9VRIqA3wBfVdX6/q5PXxKRS4Cdqvpaf9flKIsC04B7VfV0oIlgDGt0yh/DngeMBk4ECkXkqv6t1THhiDIuiKFfCYzIeV6B95UwkEQkhhf4j6jqb/3iGhEZ5r8+DNjZX/XrA2cAl4rIVryhu4+IyMMEu83g/buuVNW/+s8fx9sJBLnd5wFbVLVWVdPAb4EPE+w25+qsnUeUcUEM/RXAGBEZLSJxvAMeS/q5Tn1CRARvjHe9qv5XzktLgGv8x9cATx7tuvUVVb1FVStUdRTe3/YPqnoVAW4zgKruALaJyDi/6FxgHcFu93vAbBEp8P+tn4t33CrIbc7VWTuXAPNFJCEio4ExwKvd3qqqBu4GXAz8DdgMfL2/69OH7TwT72vdm8Ab/u1ioAzvaP9G/35Qf9e1j9o/F3jKfxz4NgNTgZX+3/sJoDTo7Qa+BbwNrAF+ASSC2GbgUbzjFmm8nvy1XbUT+LqfbxuAi3ryXjYNgzHGhEgQh3eMMcZ0wkLfGGNCxELfGGNCxELfGGNCxELfGGNCxELfGGNCxELfGGNC5P8D8wt8e4/XcN0AAAAASUVORK5CYII=\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "import matplotlib.pyplot as plt\n",
    "# 绘图训练loss\n",
    "loss = history.history['loss']\n",
    "val_loss = history.history['val_loss']\n",
    "\n",
    "plt.plot(loss, label='train Loss')\n",
    "plt.plot(val_loss, label='Validation Loss')\n",
    "plt.title('train and Validation Loss')\n",
    "plt.legend()\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 194,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "训练集MAE: 520.2074674455282\n",
      "验证集MAE: 534.4770679639181\n"
     ]
    }
   ],
   "source": [
    "from sklearn.metrics import mean_absolute_error\n",
    "print(\"训练集MAE:\",mean_absolute_error(y_train,model.predict(x_train)))\n",
    "print(\"验证集MAE:\",mean_absolute_error(y_test,model.predict(x_test)))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 195,
   "metadata": {
    "collapsed": true,
    "jupyter": {
     "outputs_hidden": true
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Epoch 1/200\n",
      "147/147 [==============================] - 1s 8ms/step - loss: 4762.1821\n",
      "Epoch 2/200\n",
      "147/147 [==============================] - 1s 8ms/step - loss: 2167.5889\n",
      "Epoch 3/200\n",
      "147/147 [==============================] - 1s 8ms/step - loss: 1223.9072\n",
      "Epoch 4/200\n",
      "147/147 [==============================] - 1s 8ms/step - loss: 1051.6530\n",
      "Epoch 5/200\n",
      "147/147 [==============================] - 1s 8ms/step - loss: 945.6614\n",
      "Epoch 6/200\n",
      "147/147 [==============================] - 1s 8ms/step - loss: 882.6482\n",
      "Epoch 7/200\n",
      "147/147 [==============================] - 1s 8ms/step - loss: 840.5568\n",
      "Epoch 8/200\n",
      "147/147 [==============================] - 1s 8ms/step - loss: 812.6485\n",
      "Epoch 9/200\n",
      "147/147 [==============================] - 1s 8ms/step - loss: 786.7043\n",
      "Epoch 10/200\n",
      "147/147 [==============================] - 1s 9ms/step - loss: 763.2664\n",
      "Epoch 11/200\n",
      "147/147 [==============================] - 1s 9ms/step - loss: 747.1034\n",
      "Epoch 12/200\n",
      "147/147 [==============================] - 1s 9ms/step - loss: 730.7169\n",
      "Epoch 13/200\n",
      "147/147 [==============================] - 1s 9ms/step - loss: 711.5103\n",
      "Epoch 14/200\n",
      "147/147 [==============================] - 1s 10ms/step - loss: 695.3455\n",
      "Epoch 15/200\n",
      "147/147 [==============================] - 1s 10ms/step - loss: 679.1757\n",
      "Epoch 16/200\n",
      "147/147 [==============================] - 1s 10ms/step - loss: 663.0501\n",
      "Epoch 17/200\n",
      "147/147 [==============================] - 1s 10ms/step - loss: 648.1343\n",
      "Epoch 18/200\n",
      "147/147 [==============================] - 1s 9ms/step - loss: 637.5474\n",
      "Epoch 19/200\n",
      "147/147 [==============================] - 1s 10ms/step - loss: 624.7227\n",
      "Epoch 20/200\n",
      "147/147 [==============================] - 2s 10ms/step - loss: 617.1621\n",
      "Epoch 21/200\n",
      "147/147 [==============================] - 1s 10ms/step - loss: 607.1274\n",
      "Epoch 22/200\n",
      "147/147 [==============================] - 1s 9ms/step - loss: 599.6153\n",
      "Epoch 23/200\n",
      "147/147 [==============================] - 1s 9ms/step - loss: 596.8032\n",
      "Epoch 24/200\n",
      "147/147 [==============================] - 1s 9ms/step - loss: 589.4604\n",
      "Epoch 25/200\n",
      "147/147 [==============================] - 1s 10ms/step - loss: 581.4316\n",
      "Epoch 26/200\n",
      "147/147 [==============================] - 1s 10ms/step - loss: 578.9745\n",
      "Epoch 27/200\n",
      "147/147 [==============================] - 1s 10ms/step - loss: 572.8922\n",
      "Epoch 28/200\n",
      "147/147 [==============================] - 2s 11ms/step - loss: 568.3447\n",
      "Epoch 29/200\n",
      "147/147 [==============================] - 1s 10ms/step - loss: 564.7056\n",
      "Epoch 30/200\n",
      "147/147 [==============================] - 1s 9ms/step - loss: 563.6768\n",
      "Epoch 31/200\n",
      "147/147 [==============================] - 2s 10ms/step - loss: 557.6375\n",
      "Epoch 32/200\n",
      "147/147 [==============================] - 1s 10ms/step - loss: 557.7881\n",
      "Epoch 33/200\n",
      "147/147 [==============================] - 2s 10ms/step - loss: 554.6555: 0s - \n",
      "Epoch 34/200\n",
      "147/147 [==============================] - 1s 8ms/step - loss: 551.3795\n",
      "Epoch 35/200\n",
      "147/147 [==============================] - 1s 8ms/step - loss: 550.3611\n",
      "Epoch 36/200\n",
      "147/147 [==============================] - 1s 8ms/step - loss: 547.8998\n",
      "Epoch 37/200\n",
      "147/147 [==============================] - 2s 11ms/step - loss: 546.7864\n",
      "Epoch 38/200\n",
      "147/147 [==============================] - 1s 9ms/step - loss: 545.6028\n",
      "Epoch 39/200\n",
      "147/147 [==============================] - 1s 8ms/step - loss: 544.2377\n",
      "Epoch 40/200\n",
      "147/147 [==============================] - 1s 8ms/step - loss: 542.1041\n",
      "Epoch 41/200\n",
      "147/147 [==============================] - 1s 10ms/step - loss: 542.1414\n",
      "Epoch 42/200\n",
      "147/147 [==============================] - 1s 9ms/step - loss: 538.4009\n",
      "Epoch 43/200\n",
      "147/147 [==============================] - 1s 10ms/step - loss: 537.4473\n",
      "Epoch 44/200\n",
      "147/147 [==============================] - 1s 9ms/step - loss: 540.9252\n",
      "Epoch 45/200\n",
      "147/147 [==============================] - 1s 9ms/step - loss: 535.4205\n",
      "Epoch 46/200\n",
      "147/147 [==============================] - 1s 9ms/step - loss: 536.2004\n",
      "Epoch 47/200\n",
      "147/147 [==============================] - 1s 9ms/step - loss: 532.5006\n",
      "Epoch 48/200\n",
      "147/147 [==============================] - 1s 9ms/step - loss: 531.1566\n",
      "Epoch 49/200\n",
      "147/147 [==============================] - 1s 9ms/step - loss: 530.6012\n",
      "Epoch 50/200\n",
      "147/147 [==============================] - 1s 10ms/step - loss: 528.9097\n",
      "Epoch 51/200\n",
      "147/147 [==============================] - 1s 9ms/step - loss: 529.9960\n",
      "Epoch 52/200\n",
      "147/147 [==============================] - 1s 9ms/step - loss: 530.4736\n",
      "Epoch 53/200\n",
      "147/147 [==============================] - 1s 10ms/step - loss: 529.8187\n",
      "Epoch 54/200\n",
      "147/147 [==============================] - 1s 9ms/step - loss: 527.9379\n",
      "Epoch 55/200\n",
      "147/147 [==============================] - 1s 9ms/step - loss: 525.3557\n",
      "Epoch 56/200\n",
      "147/147 [==============================] - 1s 10ms/step - loss: 525.3276\n",
      "Epoch 57/200\n",
      "147/147 [==============================] - 2s 11ms/step - loss: 524.9349\n",
      "Epoch 58/200\n",
      "147/147 [==============================] - 1s 10ms/step - loss: 525.8084\n",
      "Epoch 59/200\n",
      "147/147 [==============================] - 2s 11ms/step - loss: 524.7614\n",
      "Epoch 60/200\n",
      "147/147 [==============================] - 2s 10ms/step - loss: 523.1528\n",
      "Epoch 61/200\n",
      "147/147 [==============================] - 1s 10ms/step - loss: 521.6284\n",
      "Epoch 62/200\n",
      "147/147 [==============================] - 1s 10ms/step - loss: 524.0200\n",
      "Epoch 63/200\n",
      "147/147 [==============================] - 1s 10ms/step - loss: 522.7814\n",
      "Epoch 64/200\n",
      "147/147 [==============================] - 1s 10ms/step - loss: 522.3369\n",
      "Epoch 65/200\n",
      "147/147 [==============================] - 1s 10ms/step - loss: 520.9316\n",
      "Epoch 66/200\n",
      "147/147 [==============================] - 1s 10ms/step - loss: 520.6862\n",
      "Epoch 67/200\n",
      "147/147 [==============================] - 1s 10ms/step - loss: 517.6198\n",
      "Epoch 68/200\n",
      "147/147 [==============================] - 1s 10ms/step - loss: 516.0399: 0s - los\n",
      "Epoch 69/200\n",
      "147/147 [==============================] - 1s 10ms/step - loss: 516.0290: 0s\n",
      "Epoch 70/200\n",
      "147/147 [==============================] - 1s 10ms/step - loss: 515.4493\n",
      "Epoch 71/200\n",
      "147/147 [==============================] - 1s 9ms/step - loss: 515.4243\n",
      "Epoch 72/200\n",
      "147/147 [==============================] - 1s 9ms/step - loss: 516.4219\n",
      "Epoch 73/200\n",
      "147/147 [==============================] - 1s 10ms/step - loss: 515.0346\n",
      "Epoch 74/200\n",
      "147/147 [==============================] - 1s 10ms/step - loss: 514.4006\n",
      "Epoch 75/200\n",
      "147/147 [==============================] - 1s 9ms/step - loss: 514.5183\n",
      "Epoch 76/200\n",
      "147/147 [==============================] - 1s 9ms/step - loss: 512.8777\n",
      "Epoch 77/200\n",
      "147/147 [==============================] - 1s 9ms/step - loss: 512.6285\n",
      "Epoch 78/200\n",
      "147/147 [==============================] - 1s 9ms/step - loss: 513.3922\n",
      "Epoch 79/200\n",
      "147/147 [==============================] - 1s 9ms/step - loss: 512.0450\n",
      "Epoch 80/200\n",
      "147/147 [==============================] - 1s 9ms/step - loss: 510.1385\n",
      "Epoch 81/200\n",
      "147/147 [==============================] - 1s 9ms/step - loss: 512.8936\n",
      "Epoch 82/200\n",
      "147/147 [==============================] - 1s 9ms/step - loss: 509.9603\n",
      "Epoch 83/200\n",
      "147/147 [==============================] - 1s 9ms/step - loss: 509.0690\n",
      "Epoch 84/200\n",
      "147/147 [==============================] - 1s 9ms/step - loss: 509.2346\n",
      "Epoch 85/200\n",
      "147/147 [==============================] - 1s 9ms/step - loss: 510.1190\n",
      "Epoch 86/200\n",
      "147/147 [==============================] - 1s 9ms/step - loss: 509.8422\n",
      "Epoch 87/200\n",
      "147/147 [==============================] - 1s 9ms/step - loss: 509.2374\n",
      "Epoch 88/200\n",
      "147/147 [==============================] - 1s 9ms/step - loss: 506.5638\n",
      "Epoch 89/200\n",
      "147/147 [==============================] - 1s 10ms/step - loss: 507.6895\n",
      "Epoch 90/200\n",
      "147/147 [==============================] - 1s 9ms/step - loss: 507.2002\n",
      "Epoch 91/200\n",
      "147/147 [==============================] - 1s 9ms/step - loss: 505.9136\n",
      "Epoch 92/200\n",
      "147/147 [==============================] - 1s 9ms/step - loss: 505.5063\n",
      "Epoch 93/200\n",
      "147/147 [==============================] - 1s 9ms/step - loss: 504.7866\n",
      "Epoch 94/200\n",
      "147/147 [==============================] - 1s 9ms/step - loss: 505.0464\n",
      "Epoch 95/200\n",
      "147/147 [==============================] - ETA: 0s - loss: 505.576 - 1s 9ms/step - loss: 506.1465\n",
      "Epoch 96/200\n",
      "147/147 [==============================] - 1s 9ms/step - loss: 505.6296\n",
      "Epoch 97/200\n",
      "147/147 [==============================] - 1s 9ms/step - loss: 504.6172\n",
      "Epoch 98/200\n",
      "147/147 [==============================] - 1s 9ms/step - loss: 502.7805\n",
      "Epoch 99/200\n",
      "147/147 [==============================] - 1s 9ms/step - loss: 501.2663\n",
      "Epoch 100/200\n",
      "147/147 [==============================] - 1s 9ms/step - loss: 503.1049\n",
      "Epoch 101/200\n",
      "147/147 [==============================] - 1s 9ms/step - loss: 504.2404\n",
      "Epoch 102/200\n",
      "147/147 [==============================] - 1s 9ms/step - loss: 502.3691\n",
      "Epoch 103/200\n",
      "147/147 [==============================] - 1s 9ms/step - loss: 502.4935\n",
      "Epoch 104/200\n",
      "147/147 [==============================] - 1s 9ms/step - loss: 499.3574\n",
      "Epoch 105/200\n",
      "147/147 [==============================] - 1s 9ms/step - loss: 502.0828\n",
      "Epoch 106/200\n",
      "147/147 [==============================] - 1s 9ms/step - loss: 500.3568\n",
      "Epoch 107/200\n",
      "147/147 [==============================] - 1s 9ms/step - loss: 500.7452\n",
      "Epoch 108/200\n",
      "147/147 [==============================] - 1s 9ms/step - loss: 498.1072\n",
      "Epoch 109/200\n",
      "147/147 [==============================] - 1s 9ms/step - loss: 499.2495\n",
      "Epoch 110/200\n",
      "147/147 [==============================] - 1s 9ms/step - loss: 499.7784\n",
      "Epoch 111/200\n",
      "147/147 [==============================] - 1s 9ms/step - loss: 499.7461\n",
      "Epoch 112/200\n",
      "147/147 [==============================] - 1s 9ms/step - loss: 498.8126\n",
      "Epoch 113/200\n",
      "147/147 [==============================] - 1s 9ms/step - loss: 496.3974\n",
      "Epoch 114/200\n",
      "147/147 [==============================] - 1s 9ms/step - loss: 498.3484\n",
      "Epoch 115/200\n",
      "147/147 [==============================] - 1s 9ms/step - loss: 496.7365\n",
      "Epoch 116/200\n",
      "147/147 [==============================] - 1s 10ms/step - loss: 497.2639\n",
      "Epoch 117/200\n",
      "147/147 [==============================] - 1s 9ms/step - loss: 496.8339\n",
      "Epoch 118/200\n",
      "147/147 [==============================] - 1s 10ms/step - loss: 496.7951\n",
      "Epoch 119/200\n",
      "147/147 [==============================] - 1s 10ms/step - loss: 496.5878\n",
      "Epoch 120/200\n",
      "147/147 [==============================] - 1s 9ms/step - loss: 494.7966\n",
      "Epoch 121/200\n",
      "147/147 [==============================] - 1s 9ms/step - loss: 497.1125\n",
      "Epoch 122/200\n",
      "147/147 [==============================] - 1s 10ms/step - loss: 492.9515\n",
      "Epoch 123/200\n",
      "147/147 [==============================] - 1s 10ms/step - loss: 494.3411\n",
      "Epoch 124/200\n",
      "147/147 [==============================] - 1s 10ms/step - loss: 494.2662\n",
      "Epoch 125/200\n",
      "147/147 [==============================] - 1s 10ms/step - loss: 496.7079\n",
      "Epoch 126/200\n",
      "147/147 [==============================] - 1s 10ms/step - loss: 490.6114\n",
      "Epoch 127/200\n",
      "147/147 [==============================] - 1s 10ms/step - loss: 492.6856\n",
      "Epoch 128/200\n",
      "147/147 [==============================] - 1s 10ms/step - loss: 492.7357\n",
      "Epoch 129/200\n",
      "147/147 [==============================] - 1s 10ms/step - loss: 491.9061\n",
      "Epoch 130/200\n",
      "147/147 [==============================] - 1s 10ms/step - loss: 494.6308\n",
      "Epoch 131/200\n",
      "147/147 [==============================] - 1s 10ms/step - loss: 491.1451\n",
      "Epoch 132/200\n",
      "147/147 [==============================] - 1s 10ms/step - loss: 491.7574\n",
      "Epoch 133/200\n",
      "147/147 [==============================] - 1s 10ms/step - loss: 490.6184\n",
      "Epoch 134/200\n",
      "147/147 [==============================] - 1s 10ms/step - loss: 490.3426\n",
      "Epoch 135/200\n",
      "147/147 [==============================] - 1s 10ms/step - loss: 491.4964\n",
      "Epoch 136/200\n",
      "147/147 [==============================] - 1s 10ms/step - loss: 490.2032\n",
      "Epoch 137/200\n",
      "147/147 [==============================] - 1s 10ms/step - loss: 490.0134\n",
      "Epoch 138/200\n",
      "147/147 [==============================] - 1s 10ms/step - loss: 489.4862\n",
      "Epoch 139/200\n",
      "147/147 [==============================] - 1s 10ms/step - loss: 487.6873\n",
      "Epoch 140/200\n",
      "147/147 [==============================] - 1s 10ms/step - loss: 488.8812\n",
      "Epoch 141/200\n",
      "147/147 [==============================] - 1s 10ms/step - loss: 489.2485\n",
      "Epoch 142/200\n",
      "147/147 [==============================] - 1s 10ms/step - loss: 487.2769\n",
      "Epoch 143/200\n",
      "147/147 [==============================] - 1s 10ms/step - loss: 485.5349\n",
      "Epoch 144/200\n",
      "147/147 [==============================] - 1s 10ms/step - loss: 487.4033\n",
      "Epoch 145/200\n",
      "147/147 [==============================] - 1s 10ms/step - loss: 487.2341\n",
      "Epoch 146/200\n",
      "147/147 [==============================] - 2s 10ms/step - loss: 486.0181\n",
      "Epoch 147/200\n",
      "147/147 [==============================] - 2s 11ms/step - loss: 487.7747\n",
      "Epoch 148/200\n",
      "147/147 [==============================] - 2s 11ms/step - loss: 485.1398\n",
      "Epoch 149/200\n",
      "147/147 [==============================] - 2s 10ms/step - loss: 483.6194\n",
      "Epoch 150/200\n",
      "147/147 [==============================] - 2s 10ms/step - loss: 485.8663\n",
      "Epoch 151/200\n",
      "147/147 [==============================] - 1s 10ms/step - loss: 486.3058\n",
      "Epoch 152/200\n",
      "147/147 [==============================] - 2s 11ms/step - loss: 484.2478\n",
      "Epoch 153/200\n",
      "147/147 [==============================] - 2s 12ms/step - loss: 486.2424\n",
      "Epoch 154/200\n",
      "147/147 [==============================] - 2s 10ms/step - loss: 486.2095\n",
      "Epoch 155/200\n",
      "147/147 [==============================] - 2s 11ms/step - loss: 484.0413\n",
      "Epoch 156/200\n",
      "147/147 [==============================] - 1s 8ms/step - loss: 485.4978\n",
      "Epoch 157/200\n",
      "147/147 [==============================] - 1s 9ms/step - loss: 481.2050\n",
      "Epoch 158/200\n",
      "147/147 [==============================] - 1s 10ms/step - loss: 483.4738\n",
      "Epoch 159/200\n",
      "147/147 [==============================] - 1s 9ms/step - loss: 482.1679\n",
      "Epoch 160/200\n",
      "147/147 [==============================] - 1s 10ms/step - loss: 481.9561\n",
      "Epoch 161/200\n",
      "147/147 [==============================] - 1s 10ms/step - loss: 482.7939\n",
      "Epoch 162/200\n",
      "147/147 [==============================] - 1s 9ms/step - loss: 483.6097\n",
      "Epoch 163/200\n",
      "147/147 [==============================] - 1s 9ms/step - loss: 481.1382\n",
      "Epoch 164/200\n",
      "147/147 [==============================] - 1s 9ms/step - loss: 481.7428\n",
      "Epoch 165/200\n",
      "147/147 [==============================] - 1s 9ms/step - loss: 480.0162\n",
      "Epoch 166/200\n",
      "147/147 [==============================] - 1s 9ms/step - loss: 481.4682\n",
      "Epoch 167/200\n",
      "147/147 [==============================] - 1s 9ms/step - loss: 480.7914\n",
      "Epoch 168/200\n",
      "147/147 [==============================] - 1s 9ms/step - loss: 480.0787A: 0s - loss\n",
      "Epoch 169/200\n",
      "147/147 [==============================] - 1s 9ms/step - loss: 480.5990\n",
      "Epoch 170/200\n",
      "147/147 [==============================] - 1s 9ms/step - loss: 481.5992\n",
      "Epoch 171/200\n",
      "147/147 [==============================] - 1s 9ms/step - loss: 480.6964\n",
      "Epoch 172/200\n",
      "147/147 [==============================] - 1s 10ms/step - loss: 481.0403\n",
      "Epoch 173/200\n",
      "147/147 [==============================] - 1s 9ms/step - loss: 479.6999\n",
      "Epoch 174/200\n",
      "147/147 [==============================] - 1s 9ms/step - loss: 477.8939\n",
      "Epoch 175/200\n",
      "147/147 [==============================] - 1s 10ms/step - loss: 481.5489\n",
      "Epoch 176/200\n",
      "147/147 [==============================] - 1s 10ms/step - loss: 476.8861\n",
      "Epoch 177/200\n",
      "147/147 [==============================] - 1s 10ms/step - loss: 477.5583\n",
      "Epoch 178/200\n",
      "147/147 [==============================] - 2s 11ms/step - loss: 479.1072\n",
      "Epoch 179/200\n",
      "147/147 [==============================] - 2s 10ms/step - loss: 482.8394\n",
      "Epoch 180/200\n",
      "147/147 [==============================] - 2s 11ms/step - loss: 477.2107\n",
      "Epoch 181/200\n",
      "147/147 [==============================] - 2s 11ms/step - loss: 477.5797\n",
      "Epoch 182/200\n",
      "147/147 [==============================] - 1s 10ms/step - loss: 474.3376\n",
      "Epoch 183/200\n",
      "147/147 [==============================] - 1s 10ms/step - loss: 475.1655\n",
      "Epoch 184/200\n",
      "147/147 [==============================] - 1s 9ms/step - loss: 478.8283\n",
      "Epoch 185/200\n",
      "147/147 [==============================] - 1s 9ms/step - loss: 475.7742\n",
      "Epoch 186/200\n",
      "147/147 [==============================] - 1s 10ms/step - loss: 477.5808\n",
      "Epoch 187/200\n",
      "147/147 [==============================] - 1s 9ms/step - loss: 477.9590\n",
      "Epoch 188/200\n",
      "147/147 [==============================] - 1s 9ms/step - loss: 476.3610\n",
      "Epoch 189/200\n",
      "147/147 [==============================] - 1s 10ms/step - loss: 476.0331\n",
      "Epoch 190/200\n",
      "147/147 [==============================] - 1s 10ms/step - loss: 474.7943\n",
      "Epoch 191/200\n",
      "147/147 [==============================] - 1s 10ms/step - loss: 473.7327\n",
      "Epoch 192/200\n",
      "147/147 [==============================] - 2s 11ms/step - loss: 473.6573\n",
      "Epoch 193/200\n",
      "147/147 [==============================] - 2s 10ms/step - loss: 473.4745\n",
      "Epoch 194/200\n",
      "147/147 [==============================] - 2s 11ms/step - loss: 474.1281\n",
      "Epoch 195/200\n",
      "147/147 [==============================] - 2s 11ms/step - loss: 472.4727\n",
      "Epoch 196/200\n",
      "147/147 [==============================] - 2s 10ms/step - loss: 475.7674\n",
      "Epoch 197/200\n",
      "147/147 [==============================] - 1s 9ms/step - loss: 473.9666\n",
      "Epoch 198/200\n",
      "147/147 [==============================] - 2s 11ms/step - loss: 473.0277\n",
      "Epoch 199/200\n",
      "147/147 [==============================] - 2s 11ms/step - loss: 472.2007\n",
      "Epoch 200/200\n",
      "147/147 [==============================] - 2s 12ms/step - loss: 473.2079\n"
     ]
    }
   ],
   "source": [
    "# 全量数据\n",
    "from tensorflow import keras\n",
    "model=keras.Sequential([\n",
    "    keras.layers.Dense(250,activation='relu',input_shape=[len(feature_cols)]),\n",
    "    keras.layers.Dense(250,activation='relu'),\n",
    "    keras.layers.Dense(250,activation='relu'),\n",
    "    keras.layers.Dense(1)\n",
    "])\n",
    "model.compile(loss='mean_absolute_error',optimizer='Adam')\n",
    "history2 = model.fit(x, y ,batch_size=1024, epochs=200)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 196,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAX0AAAEICAYAAACzliQjAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjMuMCwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy86wFpkAAAACXBIWXMAAAsTAAALEwEAmpwYAAAhwklEQVR4nO3de5RcZZ3u8e9v76ruTied+4WQgAkXERIkSsjJiEbxRsQLjCw5eCHocGSNokvXOIwoc+YwR1BEZ/SwDuhBRYOKwCzxiIoXRDPgIYghJpIQMAkE07l2giG3vtTld/7Yb3Wqb0l30l1V2fV81qpVu97au/Zbu6uf/da739rb3B0REakPUbUrICIilaPQFxGpIwp9EZE6otAXEakjCn0RkTqi0BcRqSMKfUkdM/u6mf33atdDpBYp9KWmmNkmM3vzsbyGu/+9u3/uKNe/zMzczM7pVf5/Q/kbepV/MJRf1qv8DWZWNLP9vW5/M8B6j/l9iwyGQl+OK2aWqcBq/gwsKVvnJGAh0NbPvFcCL4b73ra6+5het+UjUmORQVLoS80ws+8CJwM/Ca3ifzKzWaElfZWZ/QX4TZj3P8xsu5m9ZGaPmNmcstf5jpndGKbfYGatZvYpM9tpZtvM7ENHqMr3gf9qZnF4/F7gR0BXr/q+DHg9cDVwoZlNG4bN0IOZNZrZV81sa7h91cwaw3OTzeynZrbHzF40s0fNLArPfdrMtpjZPjN71szeNNx1k+OTQl9qhrtfAfwFeGdoFd9S9vTrgTOBC8PjnwOnA1OBlSRBPZATgHHADOAq4DYzm3CY+bcCTwNvDY+XAHf1M98SYIW7/xBYB7z/MK95tK4n+ZYxDzgHWAD8c3juU0ArMAWYBnwWcDM7A/gYcJ67t5Bss00jUDc5Din05Xhxg7sfcPd2AHe/0933uXsncANwjpmNG2DZHPA/3T3n7g8C+4EzjrC+u4AlIUDHD9AtswS4O0zfTd8unhNDK7z8NvqI77Sn94e673T3NuBfgSvK3td04GXhvT3qycm0CkAjcJaZZd19k7tvH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zmzp3Lo48+SqFQ4IMf/GD3vF/5yleO+f2ndshmHBkFXRVMpKb960/W8vTWvcP6mmedOJb/8c45Az5/8803s2bNGlatWgXAsmXLeOKJJ1izZk33sMc777yTiRMn0t7eznnnncell17KpEmTerzO+vXr+cEPfsA3vvENLrvsMn74wx/ygQ984Ij1u//++1m1ahWrV69m165dnHfeeSxatIi7776bCy+8kOuvv55CocDBgwdZtWoVW7ZsYc2aNQBD6loaSGpb+pGppS8ig7NgwYIe49xvvfVWzjnnHBYuXMjmzZtZv359n2Vmz57NvHnzADj33HPZtGnToNb1u9/9jve+973Eccy0adN4/etfzx/+8AfOO+88vv3tb3PDDTfw1FNP0dLSwimnnMJzzz3Hxz/+cX7xi18wduzYY36vqW3pZ9S9I1LzDtcir6TRo0d3Ty9btoxf//rXLF++nObmZt7whjf0Ow6+sbGxezqO4yF17/Rn0aJFPPLII/zsZz/jiiuu4Nprr2XJkiWsXr2aX/7yl9x2223cd9993HnnnUN8dz2lt6Wv0BeRfrS0tLBv374Bn3/ppZeYMGECzc3NPPPMMzz++OPDuv5FixZx7733UigUaGtr45FHHmHBggW88MILTJ06lQ9/+MNcddVVrFy5kl27dlEsFrn00kv53Oc+x8qVK495/alt6cdm5IvFaldDRGrMpEmTOP/885k7dy5ve9vbePvb397j+cWLF/P1r3+dV77ylZxxxhksXLjwmNZ344038tWvfrX78ebNm1m+fDnnnHMOZsYtt9zCCSecwNKlS/nSl75ENptlzJgx3HXXXWzZsoUPfehDFEOWfeELXzimugDYQF81asX8+fP9aC6icsW3fs+Bzjz3f/T8EaiViBytdevWceaZZ1a7GqnS3zY1syfdfX7vedPbvaMDuSIifaQ29DVkU0Skr9SGftLSr3YtRKQ/td6tfDwZ6rZMbehnIqOo7h2RmtPU1MTu3bsV/MOgdD79pqamQS+T3tE7kUbviNSimTNn0traSltbW7WrkgqlK2cNVmpDP4oMNfRFak82mx30VZ5k+KW6e0ejd0REekpt6GvIpohIX6kN/ThCoS8i0kuKQ1/j9EVEekt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OAVwG/D0UfC1/F76x0N0rgwK/M7EkzuzqUTXP3bZB8IIGpVahXyeX0/Ees9vaCgbdPrX3u/g74ednj2Wb2RzP7TzN7XRXq09/frla22euAHe6+vqys4turVz6M2OcsjaHf39WZqz4u1czGAD8EPunue4GvAacC84BtJF8vK+18d3818DbgGjNbVIU69MvMGoB3Af8Rimphex1OzXzuzOx6IA98PxRtA05291cB/wDcbWZjK1ilgf52tbLN3kvPxkXFt1c/+TDgrP2UDWmbpTH0W4GTyh7PBLZWqS4AmFmW5A/6fXe/H8Ddd7h7wd2LwDcYwa6Agbj71nC/E/hRqMMOM5se6j0d2FnpegVvA1a6+45Qx6pvr2Cg7VMTnzszuxJ4B/B+D53AoStgd5h+kqQf+OWVqtNh/nZV32ZmlgHeDdxbKqv09uovHxjBz1kaQ/8PwOlmNju0Fi8HHqhWZUJ/4beAde7+72Xl08tm+1tgTe9lR7heo82spTRNchBwDcm2ujLMdiXw40rWq0yP1le1t1eZgbbPA8DlZtZoZrOB04EnKlkxM1sMfBp4l7sfLCufYmZxmD4l1O25CtZroL9d1bcZ8GbgGXdvLRVUcnsNlA+M5OesEkeoK30DLiI5Cr4RuL7KdXktydevPwGrwu0i4LvAU6H8AWB6het1CskogNXA2tJ2AiYBDwPrw/3EKmyzZmA3MK6srOLbi2Snsw3IkbSwrjrc9gGuD5+5Z4G3VaFuG0j6e0ufs6+HeS8Nf+PVwErgnRWu14B/u0pts/7qFcq/A/x9r3krub0GyocR+5zpNAwiInUkjd07IiIyAIW+iEgdUeiLiNQRhb6ISB1R6IuI1BGFvohIHVHoi4jUkf8Pj1oKlb1AH3AAAAAASUVORK5CYII=\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "import matplotlib.pyplot as plt\n",
    "# 绘图训练loss\n",
    "loss = history2.history['loss']\n",
    "plt.plot(loss, label='train Loss')\n",
    "plt.title('train MAE Loss')\n",
    "plt.legend()\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 201,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Model: \"sequential_11\"\n",
      "_________________________________________________________________\n",
      "Layer (type)                 Output Shape              Param #   \n",
      "=================================================================\n",
      "dense_44 (Dense)             (None, 250)               7500      \n",
      "_________________________________________________________________\n",
      "dense_45 (Dense)             (None, 250)               62750     \n",
      "_________________________________________________________________\n",
      "dense_46 (Dense)             (None, 250)               62750     \n",
      "_________________________________________________________________\n",
      "dense_47 (Dense)             (None, 1)                 251       \n",
      "=================================================================\n",
      "Total params: 133,251\n",
      "Trainable params: 133,251\n",
      "Non-trainable params: 0\n",
      "_________________________________________________________________\n"
     ]
    }
   ],
   "source": [
    "# 模型参数\n",
    "model.summary()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 206,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "dnn预测结果统计情况：\n",
      "min -133.19678\n",
      "max 154805.83\n",
      "最小值减最大值 154939.03\n",
      "mean 10155.669\n",
      "标准差std 13686.274\n",
      "方差var 187314110.0\n"
     ]
    }
   ],
   "source": [
    "result_dnn = model.predict(X_test) # 记得这里应该放归一化以后的X_test数据\n",
    "print(\"dnn预测结果统计情况：\")\n",
    "show_stats(result_dnn)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 212,
   "metadata": {},
   "outputs": [],
   "source": [
    "# 输出结果\n",
    "result = pd.DataFrame()\n",
    "result['SaleID'] = sample_data['SaleID']\n",
    "result['price'] = result_dnn\n",
    "result.loc[result['price']<11, 'price'] = 11 # 用.loc方法赋值才可以\n",
    "result.loc[result['price']>99999, 'price'] = 99999"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 213,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>SaleID</th>\n",
       "      <th>price</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>150000</td>\n",
       "      <td>2278.686035</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>150001</td>\n",
       "      <td>3272.602783</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>150002</td>\n",
       "      <td>18536.103516</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>150003</td>\n",
       "      <td>1326.294678</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>150004</td>\n",
       "      <td>3550.604492</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>49995</th>\n",
       "      <td>199995</td>\n",
       "      <td>12989.848633</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>49996</th>\n",
       "      <td>199996</td>\n",
       "      <td>38130.285156</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>49997</th>\n",
       "      <td>199997</td>\n",
       "      <td>10054.547852</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>49998</th>\n",
       "      <td>199998</td>\n",
       "      <td>8734.649414</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>49999</th>\n",
       "      <td>199999</td>\n",
       "      <td>6033.409668</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>50000 rows × 2 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "       SaleID         price\n",
       "0      150000   2278.686035\n",
       "1      150001   3272.602783\n",
       "2      150002  18536.103516\n",
       "3      150003   1326.294678\n",
       "4      150004   3550.604492\n",
       "...       ...           ...\n",
       "49995  199995  12989.848633\n",
       "49996  199996  38130.285156\n",
       "49997  199997  10054.547852\n",
       "49998  199998   8734.649414\n",
       "49999  199999   6033.409668\n",
       "\n",
       "[50000 rows x 2 columns]"
      ]
     },
     "execution_count": 213,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "result"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 214,
   "metadata": {},
   "outputs": [],
   "source": [
    "result.to_csv('./dnn.csv', index=False)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3.8.0 64-bit ('Bi_env': venv)",
   "language": "python",
   "name": "python38064bitbienvvenvba07af95a1bb4b078aa8134bba84dff2"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.0"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
